Hi,
I am trying to use inheritence to save some space and use a common handle
for subtypes until I need to identify WHICH subtypes they are.

Here is the example I have:

Table BASE
Table SUB1
Table SUB2


And I want to form an <isa> relationship like:

SUB1 <isa> BASE
SUB2 <isa> BASE

So I understand that to do this, we make the PK of SUB1 and SUB2 be a FK to
the PK of BASE.
Like so:


BASE {
PK base_id,
...
}
SUB1{
PK/FK base_id,
...
}
SUB2{
PK/FK base_id,
...
}

I want to have another table, say BASE_COLLECTION that  has  a "collection"
of BASE's like so:

MY_COLLECTION {
PK col_id,
...
}

BASE_COLLECTION {
PK base_col_id,
FK col_id (MY_COLLECTION),
FK base_id (BASE),
...
}

However If I get all of the BASE's through MY_COLLECTION -> BASE_COLLECTION
there is no way for me to determine what sub-type the BASE object really is!

Once I have a base_id from BASE_COLLECTION, how would I determine WHICH it
is? That is, without searching through all sub-types and then finding the
one that matches?
I considered having a TYPE field in the BASE table like such:

BASE {
PK base_id,
type enum{SUB1, SUB2}
...
}
Then setting up a disjoint covering constraint so that only 1 BASE can have
1 SUB-type, and then setting up a trigger so that when a sub type is
created, that it automatically updates the type field in the BASE to signify
what 'type' it is.
My question is:  how can I restrict the BASE->type field from being updated
directly, and only permit it to be updated through the trigger when a
sub-type is added/deleted?

Better yet:  Is there any good way other than the "type" method I described
to determine what sub-type the BASE really is?

thanks for your help (forgive my pseudo c/sql syntax above)


-- 
Attila
Software Developer
[EMAIL PROTECTED]



-- 
Attila
Software Developer
[EMAIL PROTECTED]

Reply via email to