05 Fifth Chapter
05 Fifth Chapter
Suhaib Al-Ansarry
specialization hierarchy, a subtype can exist only within the context of a superclass, and
every superclass can have only one superclass to which it is directly related. However, a
specialization hierarchy can have many levels of superclass / subclass relationships—
that is, you can have a specialization hierarchy in which a superclass has many
subtypes; in turn, one of the subtypes is the superclass to other lower-level subtypes.
Specialization hierarchies enable the data model to capture additional semantic content
(meaning) into the ERD. A specialization hierarchy provides the means to:
• Support attributes inheritance.
• Define a special superclass attribute known as the subclass discriminator.
• Define disjoint/overlapping constraints and complete/partial constraints.
5.1.3 Inheritance
The property of inheritance enables an entity subtype to inherit the attributes and
relationships of the superclass. As discussed earlier, a superclass contains those attributes
that are common to all of its subclass. In contrast, subclasses contain only the attributes
that are unique to the subtype. For example, Figure 5.1 illustrates that pilots, mechanics,
and accountants all inherit the employee number, last name, first name, middle initial,
hire date, and so on from the EMPLOYEE entity. However, Figure 5.1 also illustrates
that pilots have attributes that are unique; the same is true for mechanics and accountants.
One important inheritance characteristic is that all entity subclasses inherit their
Composite keys are useful to represent M:N relationships and weak (strong identifying)
entities.
In fact, composite primary keys are particularly useful in two cases:
• As identifiers of composite entities, where each primary key combination is
allowed only once in the M:N relationship.
• As identifiers of weak entities, where the weak entity has a strong identifying
relationship with the parent entity.
As shown in Figure 5.3, example of student, the composite primary key automatically
provides the benefit of ensuring that there cannot be duplicate values—that is, it ensures
that the same student cannot enroll more than once in the same class.
ReviewQuestions
1. What is an entity superclass, and why is it used?
2. What kinds of data would you store in an entity subclass?
3. What is a specialization hierarchy?
4. What is subclass completeness? Give an example of its use.
5. What is an overlapping subclass? Give an example.
6. What is the difference between partial completeness and total completeness?
For questions 7–9, refer to Figure Q5.7.
7. List all of the attributes of a movie.
8. According to the data model, is it required that every entity instance in the PRODUCT
table be associated with an entity instance in the CD table? Why, or why not?
9. Is it possible for a book to appear in the BOOK table without appearing in the
PRODUCT table? Why, or why not?