Lecture 4
Lecture 4
2
SUPERTYPE/SUBTYPE
RELATIONSHIPS
Supertype/Subtype Relationships
A new modeling construct for extending the original ER model. The extended
result model is the Enhanced ER Model
Enable us to model a general entity type (called supertype) and
Then subdivide it into several specialized entity types (called subtypes)
Example 1:
Supertype: Car
Subtypes: sedan, sports car, coupe, and so on.
Example 2:
Supertype: Vechicle
Subtypes: Car, Motorcycle, Bike, Ship, and so on.
3
SUPERTYPES AND SUBTYPES
Subtype
A subgrouping of the entities in an entity type that has attributes distinct from those
in other subgroupings
Supertype
A generic entity type that has a relationship with one or more subtypes
Example
Supertype: Student
Subtypes: Undergraduate student, Graduate students
Attribute Inheritance
An instance of a subtype is also an instance of the supertype
A subtype entity inherit all attributes of the supertype
4
Figure 3-1 Basic notation for supertype/subtype notation
a) EER notation
Chapter 3
5
Figure 3-1 Basic notation for supertype/subtype notation (cont.)
b) Microsoft Visio
Notation
Different modeling tools may have different notation for the same modeling constructs.
6
DATA MODELING WITH MANY
SUBTYPES
Case : An organization with three basic types of employees
Hourly employees
Salaried employees
Contract employees
Choices for developing a conceptual data model:
1. Define a single entity type
Advantage : simple
Disadvantage : an entity instance contain all the attributes for the three types of employees. Some of
the attributes are null.
2. Define a separate entity type for each of the entities
Advantage : simple
Disadvantage : fails to exploit common properties of employees (Redundancy).
3. Define a supertype with three subtypes
7
Figure 3-2 Employee supertype with three subtypes
(An example of data model with many subtypes)
All EMPLOYEE subtypes
will have employee
number, name, address,
and date hired
8
Item supertype with three subtypes (Library System)
13
Figure 3-3 Supertype/subtype relationships in a hospital
14
GENERALIZATION AND
SPECIALIZATION
Generalization
The process of defining a more general entity type from a set of more specialized
entity types.
(BOTTOM-UP process for creating a supertype/subtype relationship)
The common attributes are put in the supertype.
Specialization
The process of defining one or more subtypes from the supertype and forming
supertype/subtype relationship.
(TOP-DOWN process for creating a supertype/subtype relationship)
Each subtype is formed with some distinguished attributes.
15
Figure 3-4 Example of generalization process
a) Three entity types: CAR, TRUCK, and MOTORCYCLE
1. What are the common attributes for all these types of vehicles ?
2. What is the supertype/subtype relationships ?
16
Figure 3-4 Example of Generalization process
a) Generalization to VEHICLE supertype
So we put
the shared
attributes in
a supertype
Note
No subtype for motorcycle, since it has no unique attributes
The only attributes of MOTOTCYCLE are those common to all vehicles
17
Figure 3-5 Example of specialization process
b) Entity type PART
Only applies to
manufactured parts
Created 2
subtypes
20
Figure 3-6 Examples of completeness constraints
a) Total specialization rule
Figure 3-6 Examples of completeness constraints (cont.)
b) Partial specialization rule
22
CONSTRAINTS IN SUPERTYPE/SUBTYPE
RELATIONSHIPS (2/3)
Disjointness Constraints:
Whether an instance of a supertype may simultaneously be a member of two (or more)
subtypes?
Disjoint Rule:
An instance of the supertype can be only a member of ONE of the subtypes
Overlap Rule:
An instance of the supertype could be a member of more than one of the subtypes
23
Figure 3-7 Examples of disjointness constraints
a) Disjoint rule- total
PATIENT
RESIDENCE
OUTPATIENT PATIENT
24
Example: disjoint rule- partial
Slide
4- 25
Figure 3-7 Examples of disjointness constraints (cont.)
b) Overlap rule- Total
PART
M PART P PART
PART
M PART P PART
When does this situation happen ?
some parts are both manufactured and purchased, for example, consider part number 4000. At a given time, the quantity
on hand for this part might be 250, of which 100 are manufactured and the remaining 150 are purchased parts. 26
CONSTRAINTS IN SUPERTYPE/SUBTYPE
RELATIONSHIPS
Hence, we have four types of specialization/generalization:
Disjoint, total
Disjoint, partial
Overlapping, total
Overlapping, partial
27
CONSTRAINTS IN SUPERTYPE/SUBTYPE
RELATIONSHIPS (3/3)
Subtype Discriminator An attribute of the supertype whose values
determine the target subtype(s)
For disjoint subtypes
a simple attribute with different values to indicate the possible subtypes
For overlapping subtypes
a composite attribute whose subparts pertain to different subtypes. Each subpart contains a
Boolean value to indicate whether or not the instance belongs to the associated subtype
28
Figure 3-8 Introducing a subtype discriminator (disjoint rule)
29
Figure 3-9 Subtype discriminator (overlap rule)
1. Three cases:
• Y, Y
• Y, N
• N, Y
2. Why 3
cases?
30
SPECIALIZATION/GENERALIZATION HIERARCHIES,
LATTICES & SHARED SUBCLASSES
A subclass may itself have further subclasses specified on it, forming a hierarchy
or a lattice
In a lattice or hierarchy, a subclass inherits attributes not only of its direct
superclass, but also of all its predecessor superclasses
Hierarchy has a constraint that every subclass has only one superclass (called
single inheritance); this is basically a tree structure
In a lattice, a subclass can be subclass of more than one superclass (called
multiple inheritance), called shared subclass
Figure 3-10 Example of supertype/subtype hierarchy
Supertype/subtype hierarchy:
A hierarchical arrangement of
supertypes and subtypes in which each
subtype has only one supertype.
Case 2 Case 3
32
Lattice with Shared Subclass “Engineering_Manager” in Lattice
SPECIALIZATION / GENERALIZATION LATTICE
EXAMPLE (UNIVERSITY)
Slide
4- 34
ENTITY CLUSTERS
EER diagrams are difficult to read when there are too many entities and
relationships.
Solution:
Group entities and relationships into entity clusters.
Entity cluster
A set of one or more entity types and associated relationships grouped into a single abstract
(virtual) entity type
35
Figure 3-13a
Possible entity
clusters for Pine
Valley Furniture in
Microsoft Visio
Related groups
of entities could
become entity
clusters
36
Figure 3-13b EER diagram of entity clusters
for Pine Valley Furniture
More readable,
isn’t it?
37
Figure 3-14 Manufacturing entity cluster
38
PACKAGED DATA MODELS
Predefined data models
Can be customized for a particular organization’s business rules
Could be universal or industry-specific
Universal data model (also called a “pattern”)
A generic or template data model that can be reused as a starting point for a data modeling
project
39
ADVANTAGES OF PACKAGED
DATA MODELS
Use proven model components
Save time and cost
Less likelihood of data model errors
Easier to evolve and modify over time
Aid in requirements determination
Easier to read
Supertype/subtype hierarchies promote reuse
Many-to-many relationships enhance model flexibility
Vendor-supplied data model fosters integration with vendor’s applications
Universal models support inter-organizational systems
40
Figure 3-15 PARTY, PARTY ROLE, and ROLE TYPE in
a universal data model
• PARTY
(a) Basic PARTY universal
data model
• generalize persons
or organizations as
actors for the
enterprise
• ROLE TYPE
allows a specific party
to serve in different
roles during different
time periods.
• PARTY ROLE
generalizes various
roles parties can play
at different times
• A PARTY ROLE
instance is a situation
in which a PARTY
acts in a particular 41
ROLE TYPE.
Figure 3-15 (b) PARTY supertype/subtype hierarchy
One PARTY supertype with many subtypes covering many party roles
42