1 / 36

Riyadh Philanthropic Society For Science Prince Sultan College For Woman

Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems (Chapter 4: The Enhanced Entity-Relationship Model). Outline Enhanced Entity Relationship Modeling Subclasses and Superclasses

keiki
Download Presentation

Riyadh Philanthropic Society For Science Prince Sultan College For Woman

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems (Chapter 4: The Enhanced Entity-Relationship Model)

  2. Outline • Enhanced Entity Relationship Modeling • Subclasses and Superclasses • Inheritance • EER Diagram Notation • Specialization • Generalization • Constraints on Specialization & Generalization • Specialization/Generalization Hierarchies and Lattices • Categories (UNION Types) • Reading: Chapter 4 Chapter 4: The Enhanced Entity-Relationship Model 1

  3. Enhanced Entity Relationship Modeling • The ER modeling concepts are enough to represent traditional • database application. • Since late 1970s newer applications of database technology • emerged. • These include databases for engineering design (CAD), multimedia, • telecommunications, etc, which have more complex requirements. • To represent these requirements as accurately as possible designers • must use additional semantic data modeling concepts leading to the • Enhanced Entity Relationship (EER) model. Chapter 4: The Enhanced Entity-Relationship Model 2

  4. Enhanced Entity Relationship Modeling • The EER includes all the modeling concepts of the ER model plus • the concepts of: • Subclass/Superclass. • Specialization/Generalization. • Inheritance. • Categories. Chapter 4: The Enhanced Entity-Relationship Model 3

  5. Subclasses and Superclasses • Subclass: a sub-groupings of the entities in an entity type that are meaningful to the organization and need to be represented explicitly because of their significance to the database applications. • e.g. EMPLOYEE entity type may be grouped further into • SECERATARY, TECHNICIAN, ENGINEER, and MANAGER etc. • The set of entities in each of these sub-grouping is a subset of the entities that belong to the EMPLOYEE entity set. It means that every entity that is a member of one of these sub groupings is also an employee. • Each of these sub-groupings is called a subclass of the EMPLOYEE • entity and the EMPLOYEE is called superclass entity. Chapter 4: The Enhanced Entity-Relationship Model 4

  6. Subclasses and Superclasses • Superclass: a generic entity type that has a relationship with one • or more subclasses. • An entity that is a member of a subclass represents the samereal • world entity as some member of the superclass e.g. a SECRETARY entity ‘ Nahi’ is also the EMPLOYEE ‘Nahi’ • The subclass member is the same entity in the superclass but in a distinct specific role. • An entity cannot exist in the database merely by being a member • of a subclass; it must also be a member of the superclass. Chapter 4: The Enhanced Entity-Relationship Model 5

  7. Subclasses and Superclasses • A member of the subclass can be optionally included as a • member of any number of its subclasses e.g. a salaried employee who is also an engineer belongs to two subclasses ENGINEER and SALARIED EMPLOYEE of the EMPLOYEE entity type. However it is not necessary that every entity in a superclass is a member of some classes. • A class/subclass (superclass/subclass) relationship is also called • IS-A (or IS-AN) relationship. • E.g. A secretary IS-AN EMPLOYEE. Chapter 4: The Enhanced Entity-Relationship Model 5

  8. Basic Concepts and Notation • The basic concept and notation that we use for subclass and superclass is shown in Fig. • The superclass is connected with a line to a circle, which in turn is connected by a line to each subclass that has been defined. • The U- shaped symbol on each line connecting a subclass to the circle indicates that the subclass is a subset of the superclass. • It also indicates the direction of the subclass/superclass relationship.

  9. Inheritance • An entity that is a member of a subclass inherits: • All the attributes of the superclass entity. • All the relationships in which the superclass participates. • This property makes it unnecessary to include superclass attributes redundantly with the sub classes. Chapter 4: The Enhanced Entity-Relationship Model 6

  10. EER Diagram Notation Chapter 4: The Enhanced Entity-Relationship Model 7

  11. Specialization • Is the process of defining a set of subclasses of an entity type; • this entity type is called the superclass of the specialization.= and thus forms a superclass/subclass relationships. • (Top-Down). • The subclasses that form a specialization are defined on the basis • of some distinguished characteristic of superclass entities such as attributes or relationships specific to the subclass. • e.g. (SECRETARY, ENGINEER, TECHNICIAN) is a • specialization of EMPLOYEE based upon Job Type. • A superclass may have several specialization e.g. (SALARIED-EMPLOYEE, HOURLY-EMPLOYEE) is also a specialization of EMPLOYEE based upon the method of payment. Chapter 4: The Enhanced Entity-Relationship Model 8

  12. Specialization • A specialization may also consists of a single subclass only, such as {MANAGER} specialization. In such as case we do not use the circle notation. Chapter 4: The Enhanced Entity-Relationship Model 8

  13. Specialization • There are two reasons for including superclass/subclass relationship • and specialization in data model: • Certain attributes may apply to some but not to all entities of • the superclass. Thus, a subclass is defined to group the entities to which these attributes apply. • Some relationship types may be participated in only by entities • that are members of the subclass. Chapter 4: The Enhanced Entity-Relationship Model 9

  14. Specialization • In summary, specialization allows us to do the following: • Define a set of subclasses of an entity type. • Establish additional specific attributes, with each subclass. • Establish additional specific relationship types between each • subclass and other entity types or subclasses. Chapter 4: The Enhanced Entity-Relationship Model 10

  15. Generalization • Is the reverse of the specialization process, which refers to the process of defining a generalized entoty type from the given entity types. • Is the process of identifying common features among several entity types, suppressing their differences and generalizing them into a single superclass (Bottom-Up). • E.g. Entity types car and truck can be generalized into the entity • type vehicle. Chapter 4: The Enhanced Entity-Relationship Model 11

  16. Generalization Vehicle_id License_plate_no MOTOR CYCLE Vehicle_id Chapter 4: The Enhanced Entity-Relationship Model 12

  17. Generalization • The entity type MOTOR CYCLE is deliberately not included in the relationship because it does not satisfy the conditions for a subclass. From the fig. it is noticed that the only attributes of MOTOR CYCLE are those that are common to all vehicles; there are no attributes specific to motor cycles. Further MOTOR CYCLE does not have any relationship with another entity type. Thus there is no need to create a MOTOR CYCLE subclass. • It is possible to have an instance of VEHICLE that is not a member of any of its subclass. Chapter 4: The Enhanced Entity-Relationship Model 11

  18. Constraints on Specialization & Generalization • In some specializations we can determine exactly the entities that • will become members of each subclass by placing a condition on • the value of some attribute of the superclass. • Such subclasses are called predicate-defined (or condition-defined) • subclasses. • E.g. If the EMPLOYEE entity type has an attribute JobType, we can • specify the condition of membership in the SECRETARY subclass • by the predicate (JobType = ‘ Secretary’), which is called the • defining predicate of the subclass. • A predicate-defined subclass is displayed by writing the predicate • condition next to the line that connects the subclass to the circle. Chapter 4: The Enhanced Entity-Relationship Model 13

  19. Constraints on Specialization & Generalization Chapter 4: The Enhanced Entity-Relationship Model 14

  20. Constraints on Specialization & Generalization • If all subclasses have the membership condition on the same • attribute of the superclass: • The specialization itself is called an attribute-defined specialization. • The attribute is called the defining attribute of the specialization. • WE place the defining attribute name next to the arc from the circle to the superclass. • When there is no condition for determining membership in a • subclass, the subclass is called user-defined. Membership in such a sub class is determined by the database users when they apply the operation to add an entity to the subclass. Hence membership is specified individually for each entity by the user and not by any condition that may be evaluated automatically. Chapter 4: The Enhanced Entity-Relationship Model 15

  21. Constraints on Specialization & Generalization • Two other constraints may apply to a specialization: • The disjointness constraint: • which specifies that the subclasses of the specialization must • be disjoint. • (i.e. if an entity is a member of one subclass, it cannot simultaneously be a member of any other subclass of the specialization). The disjoint constraint is specified by the letter ‘d’ in the circle joining the superclass and its subclasses. • If not disjoint, overlap. • (i.e. The same entity may be a member of more than one • subclass of the specialization). The overlap rule is specified by placing the letter ‘o’ in the circle joining the superclass and its subclasses. Chapter 4: The Enhanced Entity-Relationship Model 16

  22. Constraints on Specialization & Generalization • The completeness constraint: • This constraint addresses the question whether an instance of a supertype must be also a member of at least one subtype. • The completeness constraints has two possible rules. • Which may be total specialization or partial specialization. • Total specialization constraint: specifies that every entity instance in the superclass must be a member of some subclass in the relationship (e.g. Hourly & salaried employee). Total specialization is indicated by the double line extending from the superclass to the circle. • partial specialization constraint: specifies that an entity instance of the superclass is allowed not to belong to any of the subclasses (e.g. Engineer, secretary,...etc). Partial specialization is specified by the single line from the superclass to the circle. Chapter 4: The Enhanced Entity-Relationship Model 16

  23. Constraints on Specialization & Generalization • The disjointness and completeness constraints are independent. • Four possible constraints in specialization: • Disjoint, total. • Disjoint, partial. • Overlapping, total. • Overlapping, partial. • Generalization is usually total why? d d o o • Because the superclasses is derived from the subclasses • and hence contains only the entities that are in the subclass. Chapter 4: The Enhanced Entity-Relationship Model 17

  24. Constraints on Specialization & Generalization Chapter 4: The Enhanced Entity-Relationship Model 18

  25. Constraints on Specialization & Generalization Chapter 4: The Enhanced Entity-Relationship Model 19

  26. Constraints on Specialization & Generalization • Certain insertion and deletion rules apply to specialization and • generalization as a result of the disjoint and completeness constraints: • Deleting an entity from a superclass implies that it is • automatically deleted from all the subclasses to which it • belongs. • Inserting an entity in a superclass implies that the entity is • mandatorily inserted in all predicate-defined (or attribute- • defined) subclasses for which the entity satisfies the defining • predicate. • Inserting an entity in a superclass of a total specialization • implies that the entity is mandatory inserted in at least one of • the subclasses of the specialization. Chapter 4: The Enhanced Entity-Relationship Model 20

  27. Specialization/Generalization Hierarchies and Lattices • A subclass itself may have further subclasses specified on it, • forming a hierarchy or a lattice of specializations. • A specialization hierarchy has the constraint that every subclass • participates in only one class/subclass relationship i.e. each subclass has only one parent, which results in a tree structure. • (single inheritance). • In specialization lattice a subclass can be a subclass in more than • one class/subclass relationship i.e. a subclass can have more than one parent class. Such a subclass is called a shared subclass. • (multiple inheritance). Chapter 4: The Enhanced Entity-Relationship Model 21

  28. Specialization/Generalization Lattices The shared subclass ENGINEERING_MANAGER inherits all the attributes of its superclasses SALARIED_EMPLOYEE, ENGINEER and MANAGER. Chapter 4: The Enhanced Entity-Relationship Model 22

  29. Specialization/Generalization Hierarchies and Lattices Chapter 4: The Enhanced Entity-Relationship Model 23

  30. Specialization/Generalization Hierarchies and Lattices • In a hierarchy or lattice, a subclass inherits attributes not only from its direct superclass, but also from all its predecessor superclasses e.g. an entity GRADUATE_STUDENT inherits all the attributes of that entity as a STUDENT and as a PERSON • An entity may exist in several leaf nodes (no subclasses of its own) of the hierarchy e.g. a member of GRADUATE_STUDENTmay also be a meber of RESEARCH_ASSISTANT. Chapter 4: The Enhanced Entity-Relationship Model 23

  31. Specialization/Generalization Hierarchies and Lattices • The existence of one or more sharedsubclass leads to a lattice. If no shared subclasses existed, then it isa hierarchy than a lattice. • If an attribute originating in the same superclass (PERSON) is inherited more than once via different paths (EMPLOYEE and STUDENT) in the lattice, then it should be included only once in the shared subclass (STUDENT_ASSISTAN T). Hence the attributes of PERSON are inherited only once in the STUDENT_ASSISTANT subclass. Chapter 4: The Enhanced Entity-Relationship Model 23

  32. Categories (UNION Types) • In specialization/generalization, for every superclass/subclass relationships, there is only one superclass. • A shared subclass such as ENGINEERING_MANAGER in the lattice is the subclass in three superclass/subclass relationships, where each of the three relationships has a single superclass. • However a single superclass/subclass relationship can have more than one superclass. (each representing different entity types). • Such a subclass is called a category or UNION type because it • represent a collection of objects that is a subset of the UNION of • distinct entity types. Chapter 4: The Enhanced Entity-Relationship Model 24

  33. Categories (UNION Types) Vehicle Registration Chapter 4: The Enhanced Entity-Relationship Model 25

  34. Categories (UNION Types) Chapter 4: The Enhanced Entity-Relationship Model 25

  35. Categories (UNION Types) • What is the difference between the generalization and the category? • A CATEGORY can be total or partial • A total category holds the union of all entities in its superclass (represented by a double line). • A partial category can hold a subset of the union (represented by a single line). Chapter 4: The Enhanced Entity-Relationship Model 25

More Related