1 Chapter 4 Enhanced E-R Model
2 Supertypes and Subtypes Subtype: A subgrouping of the entities in an entity type which has attributes that are distinct from those in other subgroupings. Supertype: An entity type whose subtypes share common attributes. Attributes that are shared by all entities (including the identifier) are associated with the supertype. (Fig. 4-1, 2)
3 Basic notation for supertype/subtype relationships
4 Employee supertype with three subtypes
5 Attribute Inheritance Subtype entities inherit values of all attributes of the supertype. An occurrence of a subtype is also an occurrence of the supertype.
6 Use of Supertype/Subtype There are attributes that apply to some (but not all) of the instances of an entity type. The instances of a subtype participate in a relationship unique to that subtype. (see Fig. 4-3.)
7 Supertype/subtype relationships in a hospital
8 Generalization and Specialization Generalization: The process of defining a more general entity type from a set of more specialized entity types. (Fig. 4-4) Specialization: The process of defining one or more subtypes of the supertype, and forming supertype/subtype relationships. (Fig. 4-5)
9 Example of generalization (a) Three entity types: CAR, TRUCK, and MOTORCYCLE
10 (b) Generalization to VEHICLE supertype
11 Example of specialization (a) Entity type PART
12 (b) Specialization to MANUFACTURED PART and PURCHASED PART
13 Constraints in Supertype/ Subtype Relationships Completeness Constraints: Whether an instance of a supertype must also be a member of at least one subtype. –Total Specialization Rule: Yes (Fig. 4-6a - note the double line convention) –Partial Specialization Rule: No (Fig. 4-6b)
14 Examples of completeness constraints (a) Total specialization rule
15 (b) Partial specialization rule
16 Constraints in Supertype/ Subtype Relationships Disjointness Constraints: Whether an instance of a supertype may simultaneously be a member of two (or more) subtypes. –Disjoint Rule: No –Overlap Rule: Yes (Fig. 4-7)
17 (a) Disjoint rule Examples of disjointness constraints
18 (b) Overlap rule
19 Constraints in Supertype/ Subtype Relationships Subtype Discriminators: An attribute of the supertype whose values determine the target subtype(s). –Disjoint (Fig. 4-8) –Overlapping (Fig. 4-9) Summary Example (Fig. 4-10)
20 Introducing a subtype discriminator (disjoint rule)
21 Subtype discriminator (overlap rule)
22 Example of supertype/subtype hierarchy
23 Classification of business rules
24 Data model segment for class scheduling
25 Sample Entity Definitions 1.Name: FACULTY Type: Regular Definition: a university employee who is academically qualified to teach courses and perform other designated duties. Identifier: Faculty_ID 2.Name: COURSE Type: Regular Definition: a module of instruction in a particular subject area Identifier: Course_ID 3.Name: SECTION Type: Weak Definition: an offering of a course during a particular semester Identifier: Section_ID (partial only)
26 Sample Attribute Definitions 1.Name: Faculty_ID Domain: Person_IDs Definition: unique identifier of a faculty member Null: no 2.Name: Faculty_Name Domain: Person_Names Definition: name of a faculty member Null: no 3.Name: Course_ID Type: Course_ID Definition: unique identifier of a course Null: no
27 Sample Relationship Definitions 1.Name: Is_qualified Type: Binary M:N Description: associates each faculty member with course(s) he or she is qualified to teach based on academic preparation and experience Constraints: each faculty must be qualified to teach at least one course Attributes: Date_Qualified 2.Name: Is_scheduled Type: Binary M:N Description: associates each course with the sections that have been scheduled for that course. Constraints: identifying relationship Attributes: none
28 Sample Domain Constraints 1.Name: Person_IDs Data Type: Character Allowable Character: digits 2.Name: Person_Names Data Type: Character Max Length: 30 3.Name: Course_IDs Data Type: Character Format: ssss nnnn ssss = subject nnnn = course number
29 Relationship between attributes and domains
30 Representing a business rule (a) Simple E-R diagram segment
31 (b) Adding symbol to enforce business rule
32 Business Rule 1: For a faculty member to be assigned to teach a section of a course, the faculty member must be qualified to teach the course for which that section is scheduled.
33 Business Rule 2: For a faculty member to be assigned to teach a section of a course, the faculty member must not be assigned to teach a total of more than three course sections.