0% found this document useful (0 votes)
3 views17 pages

Chapter 6

Chapter Six discusses advanced data modeling concepts, focusing on the Extended Entity Relationship Model (EERM) and its components such as entity supertypes, subtypes, specialization hierarchies, and inheritance. It explains the importance of primary keys, surrogate keys, and the use of specialization and generalization in organizing entities. Additionally, it covers constraints like disjoint and overlapping subtypes, as well as completeness constraints in entity relationships.

Uploaded by

ali3993100
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)
3 views17 pages

Chapter 6

Chapter Six discusses advanced data modeling concepts, focusing on the Extended Entity Relationship Model (EERM) and its components such as entity supertypes, subtypes, specialization hierarchies, and inheritance. It explains the importance of primary keys, surrogate keys, and the use of specialization and generalization in organizing entities. Additionally, it covers constraints like disjoint and overlapping subtypes, as well as completeness constraints in entity relationships.

Uploaded by

ali3993100
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/ 17

Chapter Six Advanced Data Modeling Lec. Manal F.

Younis

Chapter Six

Advanced Data Modeling

The Extended Entity Relationship Model:


The extended entity relationship model (EERM), sometimes referred to as the enhanced entity
relationship model, is the result of adding more semantic constructs to the original entity
relationship (ER) model. As you might expect, a diagram using this model is called an EER
diagram (EERD).

Entity Supertypes and Subtypes:


Because most employees possess a wide range of skills and special qualifications, data modelers
must find a variety of ways to group employees based on employee characteristics. For instance,
a retail company could group employees as salaried and hourly employees, while a university
could group employees as faculty, staff, and administrators.
The grouping of employees to create various types of employees provides two important
benefits:
_ It avoids unnecessary nulls in the employee attributes when some employees have
characteristics that are not shared by other employees.
_ It enables a particular employee type to participate in relationships that are unique to that
employee type.
To illustrate those benefits, let’s explore the case of an aviation business. The aviation business
employs pilots, mechanics, secretaries, accountants, database managers, and many other types of
employees. Figure 5.1 illustrates how pilots share certain characteristics with other employees,
such as a last name (EMP_LNAME) and hire date (EMP_HIRE_DATE). On the other hand,
many pilot characteristics are not shared by other employees. For example, unlike other
employees, pilots must meet special requirements such as flight hour restrictions, flight checks,
and periodic training. Therefore, if all employee characteristics and special qualifications were
stored in a single EMPLOYEE entity, you would have a lot of nulls or you would have to make a
lot of needless dummy entries. In this case, special pilot characteristics such as EMP_LICENSE,
EMP_RATINGS, and EMP_MED_TYPE will generate nulls for employees who are not pilots.
In addition, pilots participate in some relationships that are unique to their qualifications. For
example, not all employees can fly airplanes; only employees who are pilots can participate in
the “employee flies airplane” relationship.

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.

• Relationships sometimes described in terms of “IS-A” relationships.

For example, a pilot is an employee, a mechanic is an employee, and an accountant is an


employee. It is important to understand that within a specialization hierarchy, a subtype can
exist only within the context of a supertype, and every subtype can have only one supertype
to which it is directly related. However, a specialization hierarchy can have many levels of
supertype/subtype relationships—that is, you can have a specialization hierarchy in which a
supertype has many subtypes; in turn, one of the subtypes is the supertype to other lower-
level subtypes.

• Subtype can exist only within context of supertype and every subtype can have only one
supertype to which it is directly related

• Can have many levels of supertype/subtype relationships

A specialization hierarchy provides the means to:


_ Support attribute inheritance.
_ Define a special supertype attribute known as the subtype discriminator.
_ Define disjoint/overlapping constraints and complete/partial constraints.

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.

• At implementation level, supertype and its subtype(s) depicted in specialization hierarchy


maintain a 1:1 relationship

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

Emp_No Pilot Emp_No. Mechnic


1 2
4 3
5

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.

Disjoint and Overlapping Constraints:


• Disjoint subtypes

– Also known as non-overlapping subtypes

– Subtypes that contain unique subset of supertype entity set

Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 4
Chapter Six Advanced Data Modeling Lec. Manal F. Younis

• Overlapping subtypes

– Subtypes that contain nonunique subsets of supertype entity set

Completeness Constraint:
• Specifies whether each entity supertype occurrence must also be member of at least one
subtype

• Can be partial or total

Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 5
Chapter Six Advanced Data Modeling Lec. Manal F. Younis

The completeness constraint specifies whether each entity supertype occurrence


must also be a member of at least one subtype. The completeness constraint can be
partial or total.
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.

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

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

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.

Specialization and Generalization:


• Specialization:

– Top-down process of identifying lower-level, more specific entity subtypes from


higher-level entity supertype

– Based on grouping unique characteristics and relationships of the subtypes

• Generalization:

– Bottom-up process of identifying higher-level, more generic entity supertype from


lower-level entity subtypes

– Based on grouping common characteristics and relationships of the subtypes

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

• Considered “virtual” or “abstract” because it is not actually an entity in final 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.

• Temporary entity used to represent multiple entities and relationships

• Eliminate undesirable consequences

– Avoid display of attributes when entity clusters are used

Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 10
Chapter Six Advanced Data Modeling Lec. Manal F. Younis

ENTITY INTEGRITY: SELECTING PRIMARY KEYS:

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.

Natural Keys and Primary Keys:

• Natural key or natural identifier is a real-world, generally accepted identifier used to


uniquely identify real-world objects

• 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

Primary Key Guidelines:

• Attribute or combination of attributes that uniquely identifies entity instances in an entity set

• Main function is to uniquely identify an entity instance or row within a table

• Guarantee entity integrity, not to “describe” the entity

When to Use Composite Primary Keys:

• Useful as identifiers of composite entities, where each primary key combination is allowed
only once in M:N relationship

– Automatically provides benefit of ensuring that there cannot be duplicate values

• Useful as identifiers of weak entities, where weak entity has strong identifying
relationship with parent entity

– Normally used to represent:

• A real-world object that is existent dependent on another real-world object

• A real-world object that is represented in data model as two separate


entities in strong identifying relationship

Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel 12
Chapter Six Advanced Data Modeling Lec. Manal F. Younis

Surrogate Key In Database Design:


In database design, there are two ways to specify a primary key: The first is to use part of the
data as the primary key. For example, a table that includes information on employees may use
Social Security Number as the primary key. This type of key is called a natural key. The second
is to use a new field with artificially-generated values whose sole purpose is to be used as a
primary key. This is called a surrogate key.

A surrogate key has the following characteristics:


1) It is typically unique an integer.
2) It has no meaning. You will not be able to know the meaning of that row of data based on the
surrogate key value.
3) It is not visible to end users. End users should not see a surrogate key in a report.
Surrogate keys can be generated in a variety of ways, and most databases offer ways to generate
surrogate keys. For example, Oracle uses SEQUENCE, MySQL uses AUTO_INCREMENT, and
SQL Server uses IDENTITY, Microsoft Access uses an AutoNumber data type.

When To Use Surrogate Primary Keys:

• Especially helpful when there is:

– No natural key

– Selected candidate key has embedded semantic contents

– Selected candidate key is too long or cumbersome

• 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

Design Case #1: Implementing 1:1 Relationships:

• 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

Design Case #2: Maintaining History of Time-Variant Data

• 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

Design Case #3: Fan Traps

• Design trap occurs when relationship is improperly or incompletely identified

• Most common design trap is known as fan trap

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

Design Case #4: Redundant Relationships

• Redundancy is seldom a good thing in database environment

• Occur when there are multiple relationship paths between related entities

• Main concern is that redundant relationships remain consistent across model

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

You might also like