The 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
Enhanced ER model Student : Undergraduate Student : Graduate Student EER model extends original ER model with two new modeling constructs – supertype and subtype Supertype Subtype Student : Undergraduate Student : Graduate Student Guitar : Acoustic : Electric Employee : Hourly Employee : Salaried Employee : Consultant
Supertypes and Subtypes Supertype: A generic entity that has a relationship with one or more subtypes Generalized type Subtype: A subgrouping of the generic entity that has attributes distinct from those in other subgroupings Specialized type
Example – Employee Hourly Employees: Salaries Employees: Consultants 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
Option 1 EMPLOYEE Employee Number Employee Name Address Date Hired Hourly Rate Annual Salary Stock Option Contract Number Billing Rate EMPLOYEE
Option 2 HOURLY SALARIED CONSULTANT EMPLOYEE EMPLOYEE Employee Num Employee Name Address Date Hired Hourly Rate HOURLY EMPLOYEE Employee Num Employee Name Address Date Hired Annual Salary Stock Option SALARIED EMPLOYEE Employee Num Employee Name Address Date Hired Contract Num Billing Rate CONSULTANT
Option 3 All 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.
HOURLY EMPLOYEE EMPLOYEE SALARIED EMPLOYEE CONSULTANT
Relationships Inheritance Relationships at the supertype level indicate that all subtypes will participate in the relationship The instances of a subtype may participate in a relationship unique to that subtype. In this situation, the relationship is shown at the subtype 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
Figure 3-1 Basic notation for supertype/subtype notation a) EER notation
Processes to create identify supertype/subtype relationships Generalization: The process of defining a more general entity type from a set of more specialized 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.) b) Generalization to VEHICLE supertype So we put the shared attributes in a supertype Draw example Note: no subtype for motorcycle, since it has no unique attributes (remember the conditions to create subtypes?)
Vehicle Car Instance of Motorcycle Truck
Processes to create identify supertype/subtype relationships Specialization: The process of defining one or more subtypes of the supertype and forming supertype/subtype relationships. TOP-DOWN
Figure 3-5 Example of specialization a) Entity type PART Only applies to manufactured parts Applies only to purchased parts
Figure 3-5 Example of specialization (cont.) b) Specialization to MANUFACTURED PART and PURCHASED PART Note: multivalued attribute was replaced by an associative entity relationship to another entity Created 2 subtypes
Constraints in Supertype Completeness Constraints: Whether an instance of a supertype must also be a member of at least one subtype Disjointness Constraints: Whether an instance of a supertype may simultaneously be a member of two (or more) subtypes Subtype Discriminator: An attribute of the supertype whose values determine the target subtype(s) The three constraints are used in combination
Constraints in Supertype Completeness Constraints: 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)
Figure 3-6 Examples of completeness constraints a) Total specialization rule
PATIENT OUT PATIENT RESIDENT PATIENT
Figure 3-6 Examples of completeness constraints (cont.) b) Partial specialization rule
Vehicle Car Instance of Motorcycle Truck
Constraints in Supertype Disjointness Constraints: Whether an instance of a supertype may simultaneously be a member of two (or more) subtypes Disjoint Rule: An instance of the supertype can be only ONE of the subtypes Overlap Rule: An instance of the supertype could be more than one of the subtypes
Figure 3-7 Examples of disjointness constraints a) Disjoint rule
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 d Attributes shared by all employees are associated with EMPLOYEE. Attributes that are peculiar to each subtype are included with that subtype only.
Figure 3-7 Examples of disjointness constraints (cont.) b) Overlap rule
Constraints in Supertype When inserting a new supertype instance, how to determine which subtype(s) should also has corresponding entries (if any)? Subtype Discriminator: An attribute of the supertype whose values determine the target subtype(s) 2 cases: Disjoint rules and Overlap rules
Subtype Discriminator Disjoint subtypes– a simple attribute is added to the supertype with alternative values to indicate the possible subtypes
Figure 3-8 Introducing a subtype discriminator (disjoint rule)
EMPLOYEE HOURLY EMPLOYEE SALARIED EMPLOYEE CONSULTANT
Subtype Discriminator Overlapping subtypes– a composite attribute is added to the supertype. The subparts of this composite attribute pertain to different subtypes. Each subpart contains a Boolean value (Y/N) to indicate whether or not the instance belongs to the associated 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 Total specialization rule Common attributes for everyone in this university 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 Charge SAVING: Acct No, Date Opened, Balance, Interest Rate, Payment LOAN: 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.