0% found this document useful (0 votes)
67 views

Step 8: Super & Sub-Classes: - Option 8A (General Case)

The document discusses four options for representing class hierarchies in a relational database when modeling object-oriented classes and subclasses. Option 8A creates separate tables for each class and subclass. Option 8B creates a table for each disjoint subclass that includes superclass attributes. Option 8C uses a single table with an attribute to indicate subclass. Option 8D uses a table with Boolean attributes for each subclass.

Uploaded by

Elizabeth Chan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Step 8: Super & Sub-Classes: - Option 8A (General Case)

The document discusses four options for representing class hierarchies in a relational database when modeling object-oriented classes and subclasses. Option 8A creates separate tables for each class and subclass. Option 8B creates a table for each disjoint subclass that includes superclass attributes. Option 8C uses a single table with an attribute to indicate subclass. Option 8D uses a table with Boolean attributes for each subclass.

Uploaded by

Elizabeth Chan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Ref:Text

Chp. 7

Step 8: Super & Sub-classes


Sec 7.2.1

• Option 8A (General Case)


• We create a relational table for the superclass and create a relational table for
each subclass
• The primary key of each of the subclass is the primary key of the superclass
licNum Vehicle vID Vehicle(vID, licNum)
Truck(vID, weight, axleNum)
weight seatNum

Car Car(vID, seatNum, engSize)


Truck
engSize
axleNum
Works for all constraints:
Disjoint/Overlapping
Total/Partial
1
Step 8 (cont)
• Option 8B (Disjoint Total Only)
• We create a relational table for each subclass. The attributes of the superclass
are merged into each of the subclasses.
• The primary key of the subclass table is the primary key of the superclass.
licNum Vehicle vID

Total Truck(vID, licNum, weight, axleNum)


weight seatNum Car(vID, licNum, seatNum, engSize)
Truck Car
axleNum engSize

If overlapping: redundancy
if partial: may lose superclass entities
not in any subclass 2
Step 8 (cont)
• Option 8C (Disjoint Only)
• We create a single relational table for all subclasses and the superclass
• The attributes of the table is the union of all attributes plus the attribute T to
indicate the subclass to which each tuple belongs. T is NULL in tuples that do
not belong to any subclass (for partial constraints)
Vehicle(vID, licNum, vType, weight, axleNum,
licNum Vehicle vID seatNum, engSize)

In the case attribute vType is used to


weight seatNum discriminate subclasses (i.e.,
Truck Car attribute T in the definition above).
axleNum engSize
Use NULLS for those vehicles which
are not trucks or cars
3
Step 8 (cont)
• Option 8D (Overlapping)
• We create a single relational table for all subclasses
and the superclass
• The attributes of the table is the union of all
attributes plus one extra Boolean attribute for each
subclass to indicate whether or not the tuple belongs
to this subclass.

licNum Vehicle vID Vehicle(vID, licNum, T1, weight,


axleNum, T2, seatNum, engSize)
weight seatNum

Truck Car
engSize
axleNum

You might also like