EER Diagram
Subclasses, Superclasses, Inheritance
• Entity types represent both kinds of entities and sets of entities of that kind that
exist in the database (e.g. entity type EMPLOYEE)
• Often an entity type has different subgroups of its entities that need to be
represented explicitly in the database because of their significance (e.g.
SECRETARY, ENGINNER, MANAGER, TECHNICIAN …)
•
Each of these subgroups is called a subclass of the
EMPLOYEE entity type
• The EMPLOYEE entity type is called the superclass of
each of these subclasses
• The relationship between a superclass and any one of its
subclasses is called a superclass/subclass or class/subclass
or IS-A (IS-AN) relationship (e.g.
Why we need EER modeling?
ER modeling concepts discussed Chapter 3 are sufficient for representing many database schemas for "traditional" database applications,
Design more accurate database schemas that reflect the data properties and constraints more precisely.
Databases for engineering design
Manufacturing
Telecommunications
Complex software systems
Geographic Information Systems (GIs)
More complex requirements
Led to the development of additional semantic data modeling concepts
Sir Syed Sarmad Ali Shah Database Management Systems
Enhanced-ER (EER) Model Concepts
Includes all modeling concepts of basic ER
Additional concepts: subclasses/superclasses,
specialization/generalization, categories, attribute
inheritance
The resulting model is called the Enhanced-ER or
Extended ER (E2R or EER) model
It is used to model applications more completely and
accurately with additional semantics
It includes some object-oriented concepts, such as
inheritance
Sir Syed Sarmad Ali Shah
5
Subclasses and Superclasses (1)
An entity type may have additional meaningful subgroupings of its entities
Example: EMPLOYEE may be further grouped into SECRETARY, ENGINEER, MANAGER, TECHNICIAN,
SALARIED_EMPLOYEE, HOURLY_EMPLOYEE,…
Each of these groupings is a subset of EMPLOYEE entities
Each is called a subclass of EMPLOYEE
EMPLOYEE is the superclass for each of these subclasses
These are called superclass/subclass relationships.
Example: EMPLOYEE/SECRETARY, EMPLOYEE/TECHNICIAN
Sir Syed Sarmad Ali Shah
6
Subclasses and Superclasses (2)
These are also called IS-A relationships (SECRETARY IS-A EMPLOYEE, TECHNICIAN IS-A EMPLOYEE, …).
Note: An entity that is member of a subclass represents the same real-world entity as some member of the superclass
The Subclass member is the same entity in a distinct specific role
An entity cannot exist in the database merely by being a member of a subclass; it must also be a member of the superclass
A member of the superclass can be optionally included as a member of any number of its subclasses
Example: A salaried employee who is also an engineer belongs to the two subclasses ENGINEER and SALARIED_EMPLOYEE
It is not necessary that every entity in a superclass be a member of some subclass
Sir Syed Sarmad Ali Shah
7
Example
Sir Syed Sarmad Ali Shah Database Management Systems
Attribute Inheritance in Superclass /
Subclass Relationships
An entity that is member of a subclass
inherits
all attributes of the superclass
It also inherits all relationships of the
superclass
Sir Syed Sarmad Ali Shah
9
Slide 10
Subclasses and Superclasses
An entity type may have subclasses of its entities Example: EMPLOYEE may be grouped into:
SECRETARY, ENGINEER, TECHNICIAN, … Based on the EMPLOYEE’s Job
MANAGER
EMPLOYEEs who are managers
SALARIED_EMPLOYEE, HOURLY_EMPLOYEE Based on the EMPLOYEE’s method of pay
Slide 11
Subclasses and Superclasses (2)
Also called IS-A relationships
SECRETARY IS-A EMPLOYEE, TECHNICIAN IS-A
EMPLOYEE, ….
An entity cannot exist in the database merely by being a member of a subclass; it must also be a member of the superclass
Slide 12
Generalization and Specialization
The process of refining one entity types into subclass
types is called
specialization
.
A top-down process
The process identifying commonalities among different
entity types and define their superclass type is called
generalization
.
A bottom-up process
Slide 14
Condition-Defined Subclasses
Specialization based on conditions of superclass attributes. Example: High-Pay-Male and High-Paid-Female
Drawing
High-Pay-Male
d
EMPLOYEE
High-Pay-Female
salary≥100000, Sex=F
⊂
⊂
Slide 15
Discussions
d
: means disjoint, each employee can belong to at most one of thesubclass.
We do not require total participation: an employee may not be in either class
A special case of condition-defined specialization is when the condition is based on the value of a single attribute
Slide 16
An Attribute-defined Specialization
Doubled line suggests total participation: an employee must be either a male or female.
Male-EMP
d
EMPLOYEE
Female-EMP F
⊂
⊂
M
Slide 17
Attribute Inheritance in Superclass /
Subclass Relationships
An entity that is member of a subclass inherits
All attributes of the entity as a member of the superclass All relationships of the entity as a member of the superclass Example:
SECRETARY inherit the attributes Name, SSN, …, from EMPLOYEE
Slide 19
Overlapping Specialization
In an overlapping specialization, indicated by an circled o, an entity in the superclass can belong to more than one subclasses.
Located-in-DC
o
DEPARTMENT
Located-in-NY
⊂
⊂
Slide 20
Further Discussions
A specialization can have only one subclass Example: High-Pay-EMP
High-Pay-EMP EMPLOYEE
salary≥100000
Slide 21
Summary
Four types of specializations
Total (double-lined), disjoint (
d
)
Partial (single-lined), disjoint (
d
)
Total (double-lined), overlapping (
o
)
Partial (single-lined), overlapping (
o
)
A subclass may have its own (additional) attributes
A superclass may have more than one
Slide 22
Slide 23
Slide 24
User-Defined
Specialization/Generalization
If no condition determines membership, the subclass is called
user-defined
Membership in a subclass is determined by the database users by applying an operation to add an entity to the subclass
Membership in the subclass is specified individually for each entity by the user
Slide 25
Specialization/Generalization Hierarchies, Lattices &
Shared Subclasses (1)
A subclass may itself have further subclasses specified on it forms a hierarchy or a lattice
Hierarchy has a constraint that every subclass has only one
superclass (called single inheritance); this is basically a tree structure
Slide 26
Slide 27
Categories (UNION TYPES)
With specialization, all subclasses are of the same type of super-classes.
SECTARY, MANAGER, and HOURLY_EMPLOYEE are all EMPLOYEEs
In some cases, we need to super-classes to be of different entity types
Such a subclass is called a category or UNION TYPE
Slide 29
Two categories (UNION types): OWNER,
Difference b/w union and shared subclasses
In EER diagrams union types (categories) are
denoted by placing the letter U inside the circle and
the subset symbol on the line connecting the
subclass with the circle
Differences between union types & shared subclasses
An entity of a shared subclass must exist in all superclasses
An entity of a union type must exist in only one superclass
Entities in shared subclasses inherit attributes of all superclasses
EER diagram notation to represent subclasses
and specialization
Sir Syed Sarmad Ali Shah Database Management Systems
Slide 32
Summary
Introduced the EER model concepts Class/subclass relationships
Specialization and generalization Inheritance
These augment the basic ER model concepts introduced in Chapter 3