Enhanced entity-relationship model Chapter 8 1 Enhanced ER model EER model = concepts of ER model & {super class, subclass, specialization, generalization} • The EER model includes all the modeling concepts of the ER model. In addition, it includes the concepts of subclass and superclass and the related concepts of specialization and generalization. • Another concept included in the EER model is that of a category or union type which is used to represent a collection of objects (entities) that is the union of objects of different entity types. • Associated with these concepts is the important mechanism of attribute and relationship inheritance. • The database schema obtained through EER modeling is called EER schema. Pictorial representation of EER schema is called EER diagram. 2 EER model EER model incorporates more accuracy into a database design, if required. Application of EER model i) Engineering design and manufacturing (CAD/CAM) ii) Telecommunications iii) Complex software systems & iv) Geographic Information Systems (GIS) 3 4 Specialization 5 Specialization Specialization is a process of defining a set of subclasses of an entity type. superclass/subclass relationship e.g. EMPLOYEE/SECRETARY, EMPLOYEE/ENGINEER, EMPLOYEE/MANAGER, EMPLOYEE/SALARIED_EMPLOYEE Different from 1:1 relationship type 6 An attribute-defined specialization 7 Specialization Specialization allows us to do the following: • Define a set of subclasses of an entity type • Specify additional attributes of each subclass • Establish additional specific relationship types between each subclass and other entity types or other subclasses. 8 Generalization 9 Generalization Generalization defines a generalized entity type from a number of entity types. Generalization process may be viewed as being functionally inverse of specialization. Generalization is a process of synthesis. 10 Constraints on Specialization & Generalization Predicate-defined specialization – Membership of an entity in a sub class of a specialization is defined by a predicate Attribute-defined specialization – membership of an entity in a sub class of a specialization is defined by value of a single attribute (called defining attribute) User-defined specialization – membership of an entity in a sub class is defined by the database user. 11 Predicate-defined specialization 12 Attribute-defined specialization 13 Constraints on Specialization & Generalization Disjoint specialization & Overlapping specialization Partial specialization &Total specialization • A specialization is called disjoint specialization if two or more subclasses do contain the same entity otherwise it is called overlapping. • A specialization is called partial if it is not necessary for every entity of a superclass to find its place in one of the subclasses otherwise the specialization is called total specialization. 14 Overlapping specialization 15 Constraints on specialization & generalization Disjointedness & completeness are independent • • • • Disjoint and total Disjoint and partial Overlapping and total Overlapping and partial 16 Specialization Lattice ENGINEERING_MANAGER is a Shared subclass 17 Specialization Lattice 18 EER model Specialization lattice – one sub class with multiple super classes (shared sub class). Specialization hierarchy – one sub class with one super class only. Existence of at least one shared subclass leads to a lattice. 19 Specialization vs. Generalization • • • • Specialization is a process of decomposition Generalization is a process of synthesis Specialization maximizes differences among entity types Generalization minimizes differences among entity types 20 EER model – Union type/ Category Data requirements for a DB for motor vehicle registration. • The owner of a registered vehicle is either a person or a company or a bank. • A registered vehicle can be either a car or a truck. • Only registered vehicles bear license plate number. A license plate number can uniquely determine a registered vehicle. • Vehicles that are not registered have vehicle id as its key. 21 Entity types – PERSON, COMPANY & BANK 22 Union type/category 23 Entity types – CAR & TRUCK 24 Union type/category 25 EER diagram 26 Union type/Category • A union type/category is a sub class of union of multiple distinct entity types • A union type has two or more super classes that may represent distinct entity types • A union type is a subset of the union of its super classes • Selective attribute inheritance • Total / partial union type • OWNER is a category, REGISTERED_VEHICLE is a category • Super classes of a category may have different key attributes 27 A Category may be replaced by a specialization If category is total consider representing it using specialization. If the two classes represent the same type of entities and share numerous attributes, including the same key attributes, specialization / generalization is preferred; otherwise, category (union type) is more appropriate. 28 Design choices in EER • Union type should be avoided. • Do not create too many sub classes. • Sub classes with small number of local attributes should be merged with super class. • Create a sub class when it is independently associated in a relationship with other entities the super class do not participate in. • Default choice for disjoint/overlapping, total/partial are overlapping & partial. 29 An example The following narrative describes a simplified version of the organization of Olympic facilities planned for the summer Olympics. Draw an EER diagram that shows the entity types, attributes, relationships, and specializations for this application. State any assumptions you make. 30 The Olympic facilities are divided into sports complexes. Sports complexes are divided into one-sport and multi sport types. Multi sport complexes have areas of the complex designated for each sport with a location indicator (e.g. center, NE corner and soon). A complex has a location, chief organizing individual, total occupied area and so on. 31 Each complex holds a series of events (e.g. the track stadium may hold many different races). For each event there is a planned date, duration, number of participants, number of official and so on. A roster of all officials will be maintained together with the list of events each official will be involved in. 32 Different equipment is needed for the events (e.g. goal posts, poles, parallel bars) as well as for maintenance. The two types of facilities (one-sport and multi sport) will have different types of information. For each type, the number of facilities needed is kept, together with an approximate budget. 33 Museum Database Design a database to keep track of information for an art museum. Assume that the following data requirements were collected: The museum has a collection of ART_OBJECTs. Each ART_OBJECT has a unique Id_no, an Artist (if known), a Year (when it was created, if known), a Title, and a Description. The art objects are categorized in several ways, as discussed below. 34 ART_OBJECTs are categorized based on their type. There are three main types: PAINTING, SCULPTURE, and STATUE, plus another type called OTHER to accommodate objects that do not fall into one of the three main types. A PAINTING has a Paint_type (oil, watercolor, etc.), material on which it is Drawn_on (paper, canvas, wood, etc.), and Style (modern, abstract, etc.). A SCULPTURE or a statue has a Material from which it was created (wood, stone, etc.), Height, Weight, and Style. 35 An art object in the OTHER category has a Type (print, photo, etc.) and Style. ART_OBJECTs are categorized as either PERMANENT_COLLECTION (objects that are owned by the museum) and BORROWED. Information captured about objects in the PERMANENT_COLLECTION includes Date_acquired, Status (on display, on loan, or stored), and Cost. Information captured about BORROWED objects includes the collection from which it was borrowed, Date_borrowed, and Date_returned. 36 Information describing the country or culture of Origin (Italian, Egyptian, American, Indian, and so forth) and Epoch (Renaissance, Modern, Ancient, and so forth) is captured for each ART_OBJECT. The museum keeps track of ARTIST information, if known: Name, DateBorn (if known), Date_died (if not living), Country_of_origin, Epoch, Main_style, and Description. The Name is assumed to be unique. 37 Different EXHIBITIONS occur, each having a Name, Start_date, and End_date. EXHIBITIONS are related to all the art objects that were on display during the exhibition. Information is kept on other COLLECTIONS with which the museum interacts, including Name (unique), Type (museum, personal, etc.), Description, Address, Phone, and current Contact_person. Draw an EER schema diagram for this application. Discuss any assumptions you make, and that justify your EER design choices. 38