Chapter 6
Chapter 6
Younis
Chapter Six
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 1
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
Specialization Hierarchy:
• Depicts arrangement of higher-level entity supertypes (parent entities) and lower-level
entity subtypes (child entities)
Figure 5.2 shows the specialization hierarchy formed by an EMPLOYEE supertype and three
entity subtypes—PILOT, MECHANIC, and ACCOUNTANT. The specialization hierarchy
reflects the 1:1 relationship between EMPLOYEE and its subtypes. For example, a PILOT
subtype occurrence is related to one instance of the EMPLOYEE supertype, and a
MECHANIC subtype occurrence is related to one instance of the EMPLOYEE supertype.
• Subtype can exist only within context of supertype and every subtype can have only one
supertype to which it is directly related
OnlineConte
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 2
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
Inheritance:
• Enables entity subtype to inherit attributes and relationships of supertype
For example, Figure 5.2 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.
• All entity subtypes inherit their primary key attribute from their supertype
Note in Figure 5.2 that the EMP_NUM attribute is the primary key for each of the subtypes.
For example, the specialization hierarchy lets you replace the undesirable EMPLOYEE table
structure in Figure 5.1 with two tables—one representing the supertype EMPLOYEE and the
other representing the subtype PILOT.
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 3
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
Emp_No. Emp_Type
1 P
2 M
3 M
4 P
5 P
Subtype Discriminator:
• The attribute in supertype entity that determines to which entity subtype each supertype
occurrence is related
Using Figure 5.2 as your guide, note that the supertype is related to a PILOT subtype if the
EMP_TYPE has a value of “P.” If the EMP_TYPE value is “M,” the supertype is related to a
MECHANIC subtype. And if the EMP_TYPE value is “A,” the supertype is related to the
ACCOUNTANT subtype.
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 4
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
• Overlapping subtypes
Completeness Constraint:
• Specifies whether each entity supertype occurrence must also be member of at least one
subtype
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 5
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
Total completeness (symbolized by a circle over a double line) means that every
supertype occurrence must be a member of at least one subtype.
Person
P_ID P_LNAME P_FNAME
1 Ali Ahmed
2 Mohammed Mustafa
3 Asal Ali
Employee Student
P_ID Emp_Hire_Date P_ID Stu_Major
1 2/2/2002 2 Computer
3 Communication
The relationship between Person table which is supertype and the Employee,
Student tables (Subtypes).
Total completeness (symbolized by a circle over a double line) means that every
supertype occurrence must be a member of at least one subtype.
We show all persons are occurrence either in employee or student table. This
represent total completeness.
Person
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 6
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
Employee Student
P_ID Emp_Hire_Date P_ID Stu_Major
1 2/2/2002 2 Computer
Partial completeness (symbolized by a circle overa single line) means that not
every supertype occurrence is a member of a subtype; that is, there may be some
supertype occurrences that are not members of any subtype.
We show not all persons are occurrence in employee or student table. This
represent partial completeness.
In partial case the third person may be related to another table in ERD.
• Generalization:
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 7
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
• The ER Model has the power of expressing database entities in a conceptual hierarchical manner. As
the hierarchy goes up, it generalizes the view of entities, and as we go deep in the hierarchy, it gives
us the detail of every entity included.
• Going up in this structure is called generalization, where entities are clubbed together to represent a
more generalized view. For example, a particular student named Mira can be generalized along with
all the students. The entity shall be a student, and further, the student is a person. The reverse is
called specialization where a person is a student, and that student is Mira.
• Generalization
• As mentioned above, the process of generalizing entities, where the generalized entities contain the
properties of all the generalized entities, is called generalization. In generalization, a number of
entities are brought together into one generalized entity based on their similar characteristics. For
example, pigeon, house sparrow, crow and dove can all be generalized as Birds.
• Specialization
Specialization is the opposite of generalization. In specialization, a group of entities is divided into sub-
groups based on their characteristics. Take a group ‘Person’ for example. A person has name, date of
birth, gender, etc. These properties are common in all persons, human beings. But in a company, persons
can be identified as employee, employer, customer, or vendor, based on what role they play in the
company.
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 8
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
• Similarly, in a school database, persons can be specialized as teacher, student, or a staff, based on
what role they play in school as entities.
• Inheritance
• We use all the above features of ER-Model in order to create classes of objects in object-oriented
programming. The details of entities are generally hidden from the user; this process known
as abstraction.
• Inheritance is an important feature of Generalization and Specialization. It allows lower-level entities
to inherit the attributes of higher-level entities.
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 9
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
• For example, the attributes of a Person class such as name, age, and gender can be inherited by lower-
level entities such as Student or Teacher.
Entity Clustering:
• An entity cluster “virtual” entity type used to represent multiple entities and
relationships in ERD
Figure 5.5 illustrates the use of entity clusters based on the Tiny College example in Chapter
4. Note that the ERD contains two entity clusters:
_ OFFERING, which groups the COURSE and CLASS entities and relationships.
_ LOCATION, which groups the ROOM and BUILDING entities and relationships.
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 10
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
The most important characteristic of an entity is its primary key (a single attribute or some
combination of attributes), which uniquely identifies each entity instance. The primary key’s
function is to guarantee entity integrity.
Furthermore, primary keys and foreign keys work together to implement relationships in the
relational model.
Therefore, the importance of properly selecting the primary key has a direct bearing on the
efficiency and effectiveness of database implementation.
• Data modeler uses natural identifier as primary key of entity being modeled
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 11
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
• Attribute or combination of attributes that uniquely identifies entity instances in an entity set
• Useful as identifiers of composite entities, where each primary key combination is allowed
only once in M:N relationship
• Useful as identifiers of weak entities, where weak entity has strong identifying
relationship with parent entity
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 12
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
– No natural key
• If you use surrogate key, ensure that candidate key of entity in question performs
properly through use of “unique index” and “not null” constraints
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 13
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
• Foreign keys work with primary keys to properly implement relationships in relational
model
• Put primary key of the “one” side (parent entity) on the “many” side (dependent entity) as
foreign key
• A 1:1 relationship is used to ensure that two entity sets are not placed in same table
• Time-variant data refers to data whose values change over time and for which you must
keep a history of data changes
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 14
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 15
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
• Fan trap occurs when having one entity in two 1:M relationships to other entities
– Thus producing an association among other entities that is not expressed in model
• Occur when there are multiple relationship paths between related entities
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 16
Chapter Six Advanced Data Modeling Lec. Manal F. Younis
Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 17