Upload
claire-townsend
View
238
Download
2
Tags:
Embed Size (px)
Citation preview
The Enhanced E-R (EER) ModelThe Enhanced E-R (EER) Model
EER model is used to identify the model that has resulted form extending the original ER model with these new modeling constructs. These extensions make the EER model semantically similar to object-oriented data modeling.
Why EER Model?
• Business environment has changed dramatically– Business relationships become more complex, so
is business data– Business rules thus need a more powerful
modeling mechanism.• Object oriented database technology• Change in database technique is expensive
SubtypeSupertype
Enhanced ER modelEnhanced ER model
• Student : Undergraduate Student: Graduate Student
• Guitar : Acoustic : Electric
• Employee : Hourly Employee: Salaried Employee: Consultant
EER model extends original ER model with two new EER model extends original ER model with two new modeling constructs – modeling constructs – supertypesupertype and and subtypesubtype
Supertypes and SubtypesSupertypes and Subtypes
• Supertype:Supertype: A generic entity that has a A generic entity that has a relationship with one or more subtypesrelationship with one or more subtypes– Generalized typeGeneralized type
• Subtype:Subtype: A subgrouping of the generic entity A subgrouping of the generic entity that has attributes distinct from those in other that has attributes distinct from those in other subgroupingssubgroupings– Specialized typeSpecialized type
Example – Employee
• Hourly Employees:– Employee Number, Employee Name, Address,
Date Hired, Hourly Rate
• Salaries Employees:– Employee Number, Employee Name, Address,
Date Hired, Annual Salary, Stock Option
• Consultants– Employee Number, Employee Name, Address,
Date Hired, Contract Number, Billing Rate
Employee NumberEmployee NameAddressDate HiredHourly RateAnnual SalaryStock OptionContract NumberBilling Rate
EMPLOYEE
Option 1
Option 2
Employee NumEmployee NameAddressDate HiredHourly Rate
Employee NumEmployee NameAddressDate HiredContract NumBilling Rate
Employee NumEmployee NameAddressDate HiredAnnual SalaryStock Option
HOURLYEMPLOYEE
SALARIEDEMPLOYEE
CONSULTANT
Option 3All employee subtypes will have employee number, name, address, and date hired
Each employee subtype will also have its own attributes
Attribute Inheritance
• The property by which subtype entities inherit values of all attributes of the supertype– Attributes that are shared by all entities are
associated with the supertype– Attributes that are unique to a particular subtype are
associated with that subtype.• An entity instance of a subtype represents the
same entity instance of the supertype.– A member of a subtype must be a member of the
supertype– Not necessary vice versa
Figure 3-2 Employee supertype with three subtypes
All employee subtypes will have employee number, name, address, and date hired
Each employee subtype will also have its own attributes
Attributes shared by all employees are associated with EMPLOYEE. Attributes that are peculiar to each subtype are included with that subtype only.
EMPLOYEE
HOURLYEMPLOYEE
SALARIEDEMPLOYEE
CONSULTANT
Relationships InheritanceRelationships Inheritance
• Relationships at the Relationships at the supertypesupertype level indicate level indicate that all subtypes will participate in the that all subtypes will participate in the relationshiprelationship
• The instances of a The instances of a subtypesubtype may participate in may participate in a relationship unique to that subtype. In this a relationship unique to that subtype. In this situation, the relationship is shown at the situation, the relationship is shown at the subtype levelsubtype level
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
When to use supertype/subtype relationships?
• There are attributes that apply to only some instances of an entity.– Result in many Null values
• The instances of a subtype participate in a relationship unique to that subtype
Processes to create identify Processes to create identify supertype/subtype relationshipssupertype/subtype relationships
1.1. Generalization:Generalization: The process of defining a The process of defining a more general entity type from a set of more more general entity type from a set of more specialized entity types. BOTTOM-UPspecialized entity types. BOTTOM-UP
Figure 3-4 Example of generalization
a) Three entity types: CAR, TRUCK, and MOTORCYCLE
All these types of vehicles have common attributes
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(remember the conditions to create subtypes?)
b) Generalization to VEHICLE supertype
Vehicle
Car
TruckInstance ofMotorcycleInstance ofMotorcycle
Processes to create identify supertype/subtype Processes to create identify supertype/subtype relationshipsrelationships
2.2. Specialization:Specialization: The process of defining The process of defining one or more subtypes of the supertype and one or more subtypes of the supertype and forming supertype/subtype relationships. forming supertype/subtype relationships. TOP-DOWNTOP-DOWN
Figure 3-5 Example of specialization
a) Entity type PART
Only applies to manufactured parts
Applies only to purchased parts
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.)
Constraints in SupertypeConstraints in Supertype
• Completeness ConstraintsCompleteness Constraints: : Whether an instance Whether an instance of a supertype of a supertype mustmust also be a member of at least also be a member of at least one subtypeone subtype
• Disjointness ConstraintsDisjointness Constraints: : Whether an instance of Whether an instance of a supertype may a supertype may simultaneouslysimultaneously be a member of be a member of two (or more) subtypestwo (or more) subtypes
• Subtype DiscriminatorSubtype Discriminator: An : An attributeattribute of the of the supertype whose values determine the target supertype whose values determine the target subtype(s)subtype(s)
• The three constraints are used in combinationThe three constraints are used in combination
Constraints in SupertypeConstraints in Supertype
1.1. Completeness ConstraintsCompleteness Constraints: Whether an : Whether an instance of a supertype instance of a supertype mustmust also be a also be a member of at least one subtypemember of at least one subtype
– TotalTotal Specialization Rule: Yes (double line) Specialization Rule: Yes (double line)– PartialPartial Specialization Rule: No (single line) Specialization Rule: No (single line)
Figure 3-6 Examples of completeness constraints a) Total specialization rule
PATIENT
OUT PATIENT
RESIDENT PATIENT
b) Partial specialization ruleFigure 3-6 Examples of completeness constraints (cont.)
Vehicle
Car
TruckInstance ofMotorcycleInstance ofMotorcycle
Constraints in SupertypeConstraints in Supertype
2.2. Disjointness ConstraintsDisjointness Constraints: Whether an : Whether an instance of a supertype may instance of a supertype may simultaneouslysimultaneously be a member of two (or more) subtypesbe a member of two (or more) subtypes
– Disjoint RuleDisjoint Rule: An instance of the supertype can be : An instance of the supertype can be only ONE of the subtypesonly ONE of the subtypes
– Overlap RuleOverlap Rule: An instance of the supertype could : An instance of the supertype could be more than one of the subtypesbe more than one of the subtypes
a) Disjoint rule
Figure 3-7 Examples of disjointness constraints
Figure 3-2 Employee supertype with three subtypes
All employee subtypes will have employee number, name, address, and date hired
Each employee subtype will also have its own attributes
Attributes shared by all employees are associated with EMPLOYEE. Attributes that are peculiar to each subtype are included with that subtype only.
d
b) Overlap ruleFigure 3-7 Examples of disjointness constraints (cont.)
Constraints in SupertypeConstraints in Supertype
• When inserting a new supertype instance, how to When inserting a new supertype instance, how to determine which subtype(s) should also has determine which subtype(s) should also has corresponding entries (if any)? corresponding entries (if any)?
3.3. Subtype DiscriminatorSubtype Discriminator: An : An attributeattribute of the of the supertype whose values determine the target supertype whose values determine the target subtype(s)subtype(s)
– 2 cases: Disjoint rules and Overlap rules2 cases: Disjoint rules and Overlap rules
Subtype DiscriminatorSubtype Discriminator
A.A. Disjoint subtypesDisjoint subtypes– a – a simplesimple attribute attribute is added to is added to the supertype with alternative values to indicate the supertype with alternative values to indicate the possible subtypesthe possible subtypes
Figure 3-8 Introducing a subtype discriminator (disjoint rule)
EMPLOYEE
HOURLYEMPLOYEE
SALARIEDEMPLOYEE
CONSULTANT
Subtype DiscriminatorSubtype Discriminator
B.B. Overlapping subtypesOverlapping subtypes– a – a compositecomposite attribute attribute is is added to the supertype. The subparts of this added to the supertype. The subparts of this composite attribute pertain to different subtypes. composite attribute pertain to different subtypes. Each subpart contains a Boolean value (Y/N) to Each subpart contains a Boolean value (Y/N) to indicate whether or not the instance belongs to the indicate whether or not the instance belongs to the associated subtypeassociated subtype
Values of the composite attribute
Figure 3-9 Subtype discriminator (overlap rule)
PART
MANUFACTURED PART
PURCHASED PART
Supertype/subtype hierarchy
• Supertype/subtype hierarchy is a hierarchical arrangement of supertypes and subtypes, where each subtype has only one supertype.– Each subtype may also be a supertype with
subtypes
Example: University
Most general entity
Common attributes for everyone in
this university
Total specialization rule
Overlap rule
Subtype of PERSON become
suptertype of FACULTY
Business Rule
A bank has three types of accounts: checking, saving, and loan. Following are the attributes for each type of account: CHECKING: Acct No, Date Opened, Balance, Services ChargeSAVING: Acct No, Date Opened, Balance, Interest Rate, PaymentLOAN: Acct No, Date Opened, Balance, Interest Rate, Assume that each bank account must be a member of exactly one of these subtypes.
• Each case handled by the firm has a unique case number; a date opened, date closed, and judgment description are also kept on each case. A case is brought by one or more plaintiffs, and the same plaintiff may be involved in many cases. A plaintiff has a requested judgment characteristic. A case is against one or more defendants and the same defendant may be involved in many cases. A plaintiff or defendant may be a person or organization may be a defendant or a plaintiff in cases. In either situation, such legal entities are identified by an entity number, and other attributes are name and net worth.
• Each employee has a unique id and is required to store his/her name, date of birth, and skill.
• An employee may be married to another employee.• Each employee may have one or more dependents.
Dependents’ name and age are recorded. Dependents’ information does not exist without employees of the dependents.
• Each employee is supervised by one employee. An employee may supervise at most 10 other employees.
• An employee can be assigned to one or more projects. Each project is participated by two to five employees. Each project assignment is associated with hours per week the employee need to spend on.
• Each project is managed by exactly one employee. An employee may manage at most one project.