Lecture 4: Enhanced E-R Model ISOM3260, Spring 2014
Lecture 4: Enhanced E-R Model
ISOM3260, Spring 2014
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
3
Database development activities during SDLC
Top-downanalysis
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
5
Enhanced E-R Model
• Supertype and subtype• Generalization and specialization• Specifying constraints in supertype/subtype
relationships• Supertype/subtype hierarchy• Entity clustering
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
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
8
Figure 3-1: Basic notation for supertype/subtype relationships
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
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
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
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
13
Figure 3-4a: Example of generalization
Three entity types: CAR, TRUCK, and MOTORCYCLE
All these types of vehicles have common attributes
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
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
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
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)
18
Figure 3-6: Examples of completeness constraints
(a) Total specialization rule
A patient must be either an outpatient or a resident patient
19
Figure 3-6b: Partial specialization rule
A vehicle could be a car, a truck, or neither
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
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
22
Figure 3-7b: Overlap rule
A part may be both purchased and manufactured
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
24
Figure 3-8: Introducing a subtype discriminator (disjoint rule)
A simple attribute with different possible values indicating the subtype
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
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)
27
Figure 3-10: Example of supertype/subtype hierarchy
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
29
Figure 3-13a: Possible entity clusters for Pine Valley Furniture
Related groups of entities can become clusters
30
Figure 3-13b: EER diagram of entity clusters
More readable, isn’t it?
31
Figure: ER model for class scheduling
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?