the enhanced er model - university of central florida · the enhanced er model database management...
TRANSCRIPT
The Enhanced ER Model
Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung
PVFC Employees
2
Hourly
Contract
Salaried n How to represent entities
that share common properties but have one or more distinct properties?
n E.g., EMPLOYEE n Hourly (id, name, address,
hourly_rate) n Salaried (id, name, address,
annual_salary, stock_option)
n Contract (id, name, address, contract_no, billing_rate)
3
Possible Solutions n One EMPLOYEE type to embrace all possible
yet optional attributes (too much sparse data)
n Define a separate entity type for each employee type (too many redundant attributes)
n Create a hierarchy of EMPLOYEE entity types that exploits common properties yet recognizes distinct properties n Enhanced ER Model: extends original ER model
to capture such a hierarchical relationship
4
Figure 3-2 Employee supertype with three subtypes
Each employee subtype will also have its own attributes
All employee subtypes will have employee number, name, address, and date hired
5
Supertypes and Subtypes n Subtype: A subgrouping of the entities in an
entity type that has attributes distinct from those in other subgroupings
n Supertype: A generic entity type that has a relationship with one or more subtypes
n Attribute Inheritance: n Subtype entities inherit values of all attributes of
the supertype n An instance of a subtype is also an instance of the
supertype
Relationship and Supertype/subtype
6
7
Figure 3-3 Supertype/subtype relationships in a hospital Both
outpatients and resident patients are cared for by a responsible physician
Only resident patients are assigned to a bed
How to create supertype/subtype hierarchy?
8
Generalization and Specialization
n Generalization: The process of defining a more general entity type from a set of more specialized entity types. BOTTOM-UP
n Specialization: The process of defining one or more subtypes of the supertype, and forming supertype/subtype relationships. TOP-DOWN
9
Figure 3-4 Example of generalization
a) Three entity types: CAR, TRUCK, and MOTORCYCLE
All these types of vehicles have common attributes
10
Figure 3-4 Example of generalization (cont.)
So we put the shared attributes in a supertype
Note: no subtype for motorcycle, since it has no unique attributes
b) Generalization to VEHICLE supertype
11
Figure 3-5 Example of specialization
a) Entity type PART
Only applies to manufactured parts
Applies only to purchased parts
12
b) Specialization to MANUFACTURED PART and PURCHASED PART
Note: multivalued attribute was replaced by an associative entity relationship to another entity
Created 2 subtypes
Figure 3-5 Example of specialization (cont.)
13
Constraints in Supertype: Completeness and Disjointness n Completeness Constraints: Whether an
instance of a supertype must also be a member of at least one subtype n Total Specialization Rule: Yes (double line) n Partial Specialization Rule: No (single line)
n Disjointness Constraints: Whether an instance of a supertype may simultaneously be a member of two (or more) subtypes n Disjoint Rule: An instance of the supertype
can be only ONE of the subtypes n Overlap Rule: An instance of the supertype
could be more than one of the subtypes
d
o
14
Figure 3-6 Examples of completeness constraints a) Total specialization rule
15
b) Partial specialization rule Figure 3-6 Examples of completeness constraints (cont.)
16
a) Disjoint rule
Figure 3-7 Examples of disjointness constraints
17
b) Overlap rule Figure 3-7 Examples of disjointness constraints (cont.)
Overlap rule: A part may be both a manufactured part and a purchased part at the same time (but must be one or the other due to Total Specialization (double line)).
18
Subtype Discriminator n An attribute (added to the supertype)
whose values determine the target subtype(s) n Disjoint – a simple attribute with
alternative values to indicate the possible subtypes
n Overlapping – 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
19
Figure 3-8 Introducing a subtype discriminator (disjoint rule)
20
Figure 3-9 Subtype discriminator (overlap rule)
21
Figure 3-10 Example of supertype/subtype hierarchy
Ex: Ch. 3, P&E #1-2
22
Large EER Diagrams
n EER diagrams are difficult to read when there are too many entities and relationships
Related groups of entities could become clusters
23
Entity Clusters n Solution: Group
entities and relationships into entity clusters
n Entity cluster: Set of one or more entity types and associated relationships grouped into a single abstract entity type
More readable, isn’t it?
24
Packaged data models are generic models that can be customized for a particular organization’s business rules
Figure 3-15 PARTY, PARTY ROLE, and ROLE TYPE in a universal data model
(a) Basic PARTY universal data model