24
The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung

The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

The Enhanced ER Model

Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung

Page 2: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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)

Page 3: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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

Page 4: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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

Page 5: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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

Page 6: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

Relationship and Supertype/subtype

6

Page 7: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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?

Page 8: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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

Page 9: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

9

Figure 3-4 Example of generalization

a) Three entity types: CAR, TRUCK, and MOTORCYCLE

All these types of vehicles have common attributes

Page 10: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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

Page 11: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

11

Figure 3-5 Example of specialization

a) Entity type PART

Only applies to manufactured parts

Applies only to purchased parts

Page 12: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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.)

Page 13: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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

Page 14: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

14

Figure 3-6 Examples of completeness constraints a) Total specialization rule

Page 15: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

15

b) Partial specialization rule Figure 3-6 Examples of completeness constraints (cont.)

Page 16: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

16

a) Disjoint rule

Figure 3-7 Examples of disjointness constraints

Page 17: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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)).

Page 18: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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

Page 19: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

19

Figure 3-8 Introducing a subtype discriminator (disjoint rule)

Page 20: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

20

Figure 3-9 Subtype discriminator (overlap rule)

Page 21: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

21

Figure 3-10 Example of supertype/subtype hierarchy

Ex: Ch. 3, P&E #1-2

Page 22: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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

Page 23: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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?

Page 24: The Enhanced ER Model - University of Central Florida · The Enhanced ER Model Database Management Systems Reading: Hoffer Chapter 3 Dr. Wingyan Chung . PVFC Employees 2 ... Enhanced

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