Top Banner
Lecture 4: Enhanced E-R Model ISOM3260, Spring 2014
32
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Enhanced ER(database)

Lecture 4: Enhanced E-R Model

ISOM3260, Spring 2014

Page 2: Enhanced ER(database)

2

Where we are now• Database environment

– Introduction to database• Database development process

– steps to develop a database• Conceptual data modeling

– entity-relationship (ER) diagram; enhanced ER• Logical database design

– transforming ER diagram into relations; normalization• Physical database design

– technical specifications of the database• Database implementation

– Structured Query Language (SQL), Advanced SQL• Advanced topics

– data and database administration

Page 3: Enhanced ER(database)

3

Database development activities during SDLC

Top-downanalysis

Page 4: Enhanced ER(database)

4

Why Enhanced E-R Model?

• Business data are now more complex• EER improve flexibility of the basic E-R

model to represent business data• EER is the result of extending the original

E-R model with new modeling constructs

Page 5: Enhanced ER(database)

5

Enhanced E-R Model

• Supertype and subtype• Generalization and specialization• Specifying constraints in supertype/subtype

relationships• Supertype/subtype hierarchy• Entity clustering

Page 6: Enhanced ER(database)

6

Supertypes and Subtypes• Subtype

– a subgrouping of the entities in an entity type, that is meaningful to the organization, and which has attributes or relationships that are distinct from those in other subgroupings

– at the same time, the subgroupings share common attributes which are associated with the entity type

– e.g. GRADUATE STUDENT and UNDERGRADUATE STUDENT subtypes of STUDENT

Page 7: Enhanced ER(database)

7

Supertypes and Subtypes• Supertype

– a generic entity type that has a relationship with one or more subtypes

– e.g. STUDENT supertype of GRADUATE STUDENT and UNDERGRADUATE STUDENT

• Attribute Inheritance– subtype entities inherit values of all attributes

of the supertype– an instance of a subtype is also an instance of

the supertype

Page 8: Enhanced ER(database)

8

Figure 3-1: Basic notation for supertype/subtype relationships

Page 9: Enhanced ER(database)

9

Figure 3-2: Employee supertype with three subtypes

All subtypes will have Employee_Number, Employee_Name, Address, and Date_Hired

Each subtype will also have its own attributes

Page 10: Enhanced ER(database)

10

Supertype/Subtype Relationships

• Relationships at the supertype level – indicate that all subtypes will participate in the

relationship

• Relationships at the subtype level – the instances of a subtype may participate in a

relationship unique to that subtype

Page 11: Enhanced ER(database)

11

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

Page 12: Enhanced ER(database)

12

Generalization and Specialization

• Two processes to develop supertype/subtype relationships

• Generalization– the process of defining a more general entity type from a

set of more specialized entity types– bottom-up process

• Specialization– the process of defining one or more subtypes of the

supertype, and forming supertype/subtype relationships– top-down process

Page 13: Enhanced ER(database)

13

Figure 3-4a: Example of generalization

Three entity types: CAR, TRUCK, and MOTORCYCLE

All these types of vehicles have common attributes

Page 14: Enhanced ER(database)

14

Figure 3-4b: Generalization to VEHICLE supertype

So we put the shared

attributes in a supertype

No subtype for motorcycle, since it has no unique attributes

Page 15: Enhanced ER(database)

15

Figure 3-5a: Example of specialization

Applies only to manufactured

parts

Applies only to purchased parts

Parts may be manufactured internally and/or purchased from suppliers

Page 16: Enhanced ER(database)

16

Figure 3-5b: Specialization to MANUFACTURED PART and PURCHASED PART

Multivalued attribute “supplier” was replaced by a relationship to another entity

Created 2 subtypes

Page 17: Enhanced ER(database)

17

Completeness Constraints in Supertype/Subtype Relationships

• Completeness Constraint– whether an instance of a supertype must also

be a member of at least one subtype

• Total Specialization Rule– Yes (double line)

• Partial Specialization Rule– No (single line)

Page 18: Enhanced ER(database)

18

Figure 3-6: Examples of completeness constraints

(a) Total specialization rule

A patient must be either an outpatient or a resident patient

Page 19: Enhanced ER(database)

19

Figure 3-6b: Partial specialization rule

A vehicle could be a car, a truck, or neither

Page 20: Enhanced ER(database)

20

Disjointness Constraints in Supertype/Subtype Relationships

• Disjointness Constraint– whether an instance of a supertype may simultaneously be a

member of two or more subtypes• Disjoint Rule

– No (letter ‘d’)– an instance of the supertype can be only ONE of the subtypes

• Overlap Rule– Yes (letter ‘o’)– an instance of the supertype can simultaneously be a member

of two or more subtypes

Page 21: Enhanced ER(database)

21

(a) Disjoint rule

Figure 3-7: Examples of disjointness constraints

A patient can either be outpatient or resident, but not both, at any given time

Page 22: Enhanced ER(database)

22

Figure 3-7b: Overlap rule

A part may be both purchased and manufactured

Page 23: Enhanced ER(database)

23

Subtype Discriminators• A mechanism to implement supertype/subtype

relationships• Subtype Discriminator

– an attribute of the supertype whose values determine the target subtype(s)

• Disjoint subtype– a simple attribute with alternative values to indicate the

possible subtypes• Overlapping subtype

– a composite attribute whose subparts pertain to different subtypes

– each subpart contains a boolean value (‘Y’ or ‘N’) to indicate whether or not the instance belongs to the associated subtype

Page 24: Enhanced ER(database)

24

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

A simple attribute with different possible values indicating the subtype

Page 25: Enhanced ER(database)

25

Figure 3-9: Subtype discriminator (overlap rule)

A composite attribute with sub-attributes indicating “Y” or “N” to determine whether it is of each subtype

Page 26: Enhanced ER(database)

26

Supertype/Subtype Hierarchies

• Attributes are assigned at the highest logical level in the hierarchy– e.g. SSN applies to all PERSONs– e.g. Date_Hired applies only to EMPLOYEE

• Subtypes lower in the hierarchy inherit attributes from their supertypes up to the root (entity type at top of hierarchy)– e.g. an instance of FACULTY has the following attributes:– SSN, Name, Address, Gender, Date_of_Birth (from

PERSON)– Date_Hired, Salary (from EMPLOYEE)– Rank (from FACULTY)

Page 27: Enhanced ER(database)

27

Figure 3-10: Example of supertype/subtype hierarchy

Page 28: Enhanced ER(database)

28

Entity Clusters

• EER diagrams are difficult to read when there are too many entities and relationships

• Different people may be interested in different types of data

• 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 entity type

Page 29: Enhanced ER(database)

29

Figure 3-13a: Possible entity clusters for Pine Valley Furniture

Related groups of entities can become clusters

Page 30: Enhanced ER(database)

30

Figure 3-13b: EER diagram of entity clusters

More readable, isn’t it?

Page 31: Enhanced ER(database)

31

Figure: ER model for class scheduling

Page 32: Enhanced ER(database)

32

Review Questions

• What are subtypes and supertypes?• What are generalization and specialization?• What are the total and partial specialization

rules?• What are the disjoint and overlap rules?• What are subtype discriminators?• What are supertype/subtype hierarchies?• What are entity clusters?