Database Systems 主講人 : 陳建源 日期 :99/10/19 研究室 : 法 Chapter 4 Enhanced Entity-Relationship and Object Modeling
1. EER Model Concepts subclasses/superclasses specialization/generalization categories (UNION types) attribute and relationship inheritance 2. Constraints on Specialization/ Generalization 3. UNION Types Using Categories 4. An Example EER Schema Outline
Extended Entity-Relationship (EER)Model An extension of ER model includes the concepts of subclass and superclass specialization and generalization category attribute and relationship inheritance 1. EER Model Concepts
Subclass and Superclass In many cases an entity type has numerous subgroupings of its entities e.g., EMPLOYEE may be grouped into SECRETARY, ENGINEER, MANAGER, TECHNICIAN Each subgroup form a subclass of the entity type (superclass) e.g., SECRETARY ENGINEER MANAGER TECHNICIAN EMPLOYEE superclass subclass 1. EER Model Concepts
Class/subclass (IS-A/AN) relationship The relationship between a superclass and any one of its subclasses e.g., EMPLOYEE/MANAGER An entity being a member of a subclass must also be a member of the superclass e.g., a SECRETARY entity ‘Joan Logano’ is also the EMPLOYEE ‘Joan Logano’ A subclass entity is the same as that in the superclass, but in a distinct specific role 1. EER Model Concepts
Type inheritance A subclass entity inherits all the attributes of the entity as a member of the superclass all the relationships in which the superclass participates A subclass should have specific attributes and can participate in specific relationship types e.g., SECRETARY has attribute TypingSpeed 1. EER Model Concepts
Specialization The process of defining a set of subclasses of an entity type (superclass) based on some distinguishing characteristic, e.g., {SECRETARY, ENGINEER, TECHNICIAN} based on job type {SALARIED_EMPLOYEE, HOURLY_EMPLOYEE} based on method of pay 1. EER Model Concepts
EER Model Concepts (cont.)
Reasons for using (specialization) subclass Certain attributes may apply to some but not all entities of the superclass Some relationship types may be participated in only by entities that are members of the subclass 1. EER Model Concepts
Generalization The process of identifying the common features among several entity types, and generalizing them into a single superclass e.g., CAR and TRUCK can be generalized into VEHICLE Generalization can be viewed as the inverse of specialization 1. EER Model Concepts
ER Model Concepts (cont.)
Predicate-defined (or condition-defined) subclasses Placing a condition on the value the attribute that identify the subclasses e.g., SECRETARY subclass by the defining predicate JobType = ‘ Secretary ’ A constraint specifying that members of the subclass must satisfy the predicate 2. Constraints and Characteristics of Specialization/ Generalization
2. Constraints on Specialization/ Generalization
Attribute-defined specialization Specify that all subclasses having the membership condition on the same attribute of the superclass The attribute is called the defining attribute of the specialization, e.g., Job type 2. Constraints and Characteristics of Specialization/ Generalization
Disjointness constraint Specify that the subclasses of the specialization must be disjoint, i.e., an entity belongs to at most one subclass e.g., specialization {HOURLY_EMPLOYEE, SALARIED_EMPLOYEE} denoted as symbol If the subclasses are not disjoint, their sets of entities may overlap, denoted as symbol d o 2. Constraints and Characteristics of Specialization/ Generalization
Completeness constraint Total specialization constraint Specify that every entity in the superclass must be a member of some subclass in the specialization Partial specialization Allow an entity not to belong to any of the subclasses 2. Constraints and Characteristics of Specialization/ Generalization
Specialization Hierarchies and Lattices A subclass itself may have further subclasses specified on it, forming a hierarchy or a lattice of specializations For a specialization hierarchy every subclass participates in only one class/subclass For a specialization lattice a subclass can be a subclass in more than one class/subclass 2. Constraints and Characteristics of Specialization/ Generalization
A subclass with more than one superclass is called a shared subclass, leading to multiple inheritance e.g., ENGINEERING_MANAGER Any inherited attribute should be included only once in a shared subclass 2. Constraints and Characteristics of Specialization/ Generalization
Top-down conceptual refinement Start with an entity type and then define subclasses by successive specialization e.g., A university database schema PERSON => {EMPLOYEE, ALUMNUS, STUDENT} {STAFF, FACULTY, STUDENT_ASSISTANT} {RESEARCH_ASSISTANT, TEACHING_ASSISTANT} {GRADUATE_STUDENT,UNDERGRADUATE_STUDENT} 2. Constraints and Characteristics of Specialization/ Generalization
Bottom-up conceptual synthesis Start with entity types and then define superclasses by successive generalization e.g., {STAFF, FACULTY, ALUMNUS} EMPLOYEE Hybrid conceptual process A combination of the two processes 2. Constraints and Characteristics of Specialization/ Generalization
Union type (Category) Modeling a single superclass/subclass relationship with more than one superclass Superclasses can represent different entity types e.g., In a vehicle registration database, the vehicle owner can be a person, a bank, or a company => OWNER: a subclass of the UNION of COMPANY, BANK, and PERSON The union type (category) is specified via symbol, called set union operation 3. UNION Types Using Categories
A category can be total or partial e.g., Fig 4.9[5th], Fig 7.27[6th], where c1 and c2 are predicate conditions that specify which COMPANY and PERSON entities are members of ACCOUNT_HOLDER The superclasses of a category may have different key attributes e.g., OWNER category of Fig 4.8[5th], Fig 7.26[6th] have the same key attribute e.g., REGISTERED_VEHICLE category 3. UNION Types Using Categories
Category vs shared subclass A category is a subset of the union of its superclasses An entity that is a member of a category must exist in only one of the superclasses e.g., an OWNER may be a COMPANY a BANK, or a PERSON 3. UNION Types Using Categories
A shared subclass is a subset of the intersection of the superclasses An entity that is a member of the shared subclass must exist in all superclasses e.g., An engineering manager must be an ENGINEER, a MANAGER, and a SALARIED_EMPLOYEE 3. UNION Types Using Categories
Category vs generalized superclass A total category can be represented as a specialization (or a generalization) A partial category cannot be represented as a partial specialization (or a generalization) e.g., category REGISTERED_VEHICLE (Fig 4.8[5 th ], Fig 7.26[6 th ]) and generalized superclass VEHICLE (Fig 4.3(b) [5 th ], Fig 7.21(b) [6 th ])) 3. UNION Types Using Categories
A UNIVERSITY Database Example Requirements: The database keeps track Students and their majors, transcripts, and registration The university ’ s course offerings The sponsored research projects of faculty and graduate students The advisor and thesis committee of each graduate student Colleges and their related departments 4. An Example EER Schema
Initial design Entity types STUDENT COURSE FACULTY GRADUATE_STUDENT GRANT (project) 4. An Example EER Schema
DEPARTMENT (student ’ s majors) SECTION (course offerings, student ’ s registration) COLLEGE Superclass/subclass STUDENT/GRAD_STUDENT SECTION/CURRENT_SECTION (for quarter system universities) 4. An Example EER Schema
Generalization PERSON: {FACULTY, STUDENT} Category (Union type) INSTRUCTOR_RESEARCHER: {FACULTY, GRAD_STUDENT} 4. An Example EER Schema
Iterative refinement Relationship types STUDENT CURRENT_SECTION STUDENT DEPARTMENT STUDENT SECTION FACULTY DEPARTMENT FACULTY GRAD_STUDENT FACULTY GRANT 4. An Example EER Schema
INSTRUCTOR_RESEARCHER SECTION GRANT INSTRUCTOR_RESEARCHER COURSE SECTION DEPARTMENT COURSE COLLEGE DEPARTMENT Structure constraints 4. An Example EER Schema
ER Conceptual Design (cont.)
Alternative Notation
Summary Introduced the EER model concepts Class/subclass relationships Specialization and generalization Inheritance These augment the basic ER model concepts introduced in Chapter 3 EER diagrams and alternative notations were presented