Presentation is loading. Please wait.

Presentation is loading. Please wait.

Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen1 Class/subclass relationships Inheritance Specialization Generalization.

Similar presentations


Presentation on theme: "Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen1 Class/subclass relationships Inheritance Specialization Generalization."— Presentation transcript:

1 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen1 Class/subclass relationships Inheritance Specialization Generalization Constraints: subclass definition, disjointness, completeness constraints Category

2 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen2 Class/subclass relationships A subclass is a subgrouping of an entity set: If A is a class and B is a subclass of A, then each instance of B is an instance of A, has the attributes of A (and possibly others defined for B), and participates in A’s relationships (and possibly others defined for B). We illustrate as: A B B is shown as a subclass of A B is a specialization of A A is a generalization of B

3 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen3 Class/subclass relationships Suppose Employee is subclassed in many ways according to the value of the attribute jobType : Secretary, Engineer, Technician – we have a predicate-defined subclass We illustrate as: Employee SecretaryTechnicianEngineer The subclass is determined by the value of the jobType attribute; jobType is a discriminator jobType “technician” “engineer” “secretary”

4 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen4 Class/subclass relationships Suppose an Employee can be at most one of Technician, Secretary, Engineer We illustrate as: Employee SecretaryTechnicianEngineer subclasses are disjoint jobType “technician”“secretary” “engineer” d

5 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen5 Class/subclass relationships Suppose an Employee can be more than one of Technician, Secretary, Engineer – at the same point in time We illustrate as: Employee SecretaryTechnicianEngineer subclasses are overlapping jobType “technician”“secretary” “engineer” o

6 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen6 Class/subclass relationships Suppose Employee is subclassed but the decision is left to the database user – we have a user-defined subclass constraint. We illustrate as: Employee d SecretaryTechnicianEngineer No rule is shown for determining the subclass

7 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen7 Class/subclass relationships Suppose a business rule states that an Employee must be one of : Secretary, Engineer, Technician We illustrate as: d SecretaryTechnicianEngineer The double line indicates an employee must participate in the specialization. We say the subclassing is complete or total Employee

8 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen8 d SecretaryTechnicianEngineer Employee ssn birthDate tGrade tSpeed engType Dept Union Every employee is assigned to a department Only secretaries belong to a union Every employee has a SSN and a birthDate; technicians also have a tGrade attribute, …

9 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen9 Specialization hierarchy Every subclass participates in one specialization Specialization lattice Some subclass(es) participate in more than one specialization In OO modeling this situation is referred to as multiple inheritance When multiple levels occur in a specialization graph, a subclass inherits all attributes and relationships of all its ancestors. In a graph, the nodes at the lowest level are called leaf nodes. See figures: 4.1, 4.6, 4.7

10 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen10 Category A single subclass is considered to be a subset of the union of several superclasses. personcompany owner u The “u” represents the union of the three distinct and separate entity sets: person, bank, and company Owner is a subset of the union of the three sets. bank Top half of figure 4.8

11 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen11 personcompany owner u bank figure 4.8 car truck registered vehicle owns u

12 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen12 Category If every building and every lot must be an property, then buildinglot property u The double line indicates that every building and every lot must participate in the category Figure 4.9(b)

13 Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen13 Specialization If every property must be a building or a lot, then buildinglot property u On the previous slide, participation is total … one could consider using specialization in this case Figure 4.9(b)


Download ppt "Enhanced Entity-Relationship and Object Modeling (Ch 4) Jan 200692.3902 R McFadyen1 Class/subclass relationships Inheritance Specialization Generalization."

Similar presentations


Ads by Google