written 2.5 years ago by |
Subtype Discriminator
Consider the problem of inserting a new instance of a supertype.
- Into which of the subtypes (if any) should this instance be inserted?
- We need a simple mechanism to implement these rules.
- This mechanism is called Subtype Discriminator.
A subtype discriminator : is an attribute of a supertype whose values determine the target subtype or subtypes.
- Disjoint : A simple attribute with alternative values indicates the possible subtypes.
- Overlapping : a composite attribute whose subparts relate to differe subtypes.
- Each subpart contains a value indicting whether or not the instance belongs subtype.
Subtype Discriminator : Disjoint Subtypes
Constraints have been added :
- Total specialization and disjoint subtypes.
Each employee must be either :
- hourly,
- salaried,
- or a consultant.
(Employee Type) attribute has been added to the supertype
- As a subtype discriminator.
When a new employee is added to the supertype, This attribute is coded with :
- This attribute is coded with :
- "H" (for Hourly)
- "S" (for Salaried)
- "C" (for Consultant).
Depending on this code.
- The instance is then assigned to the appropriate subtype.
Subtype Discriminator : Overlapping Subtypes
When subtypes overlap, a slightly modified approach must be applied for the subtype discriminator.
A given instance of the supertype may require that we create an instance in more than one subtype.
- Example : PART and its overlapping subtypes.
- A new attribute named Part Type has been added to PART. Part Type is a composite attribute with components Manufactured? and Purchased?
- Each of these attributes is a Boolean variable
When a new instance is added to PART, these components are coded as follows :
Type of Part | Manufactured? | Purchased? |
---|---|---|
Manufactured only | "Y" | "N" |
Purchased only | "N" | "Y" |
Purchased and manufactured | "Y" | "Y" |
The values of the discriminator attribute parts will determine where the instance is going to be stored.