350 likes | 531 Views
EER Diagram. Prepared BY : Sir Syed Sarmad Ali. Subclasses, Superclasses , Inheritance. • Entity types represent both kinds of entities and sets of entities of that kind that exist in the database (e.g. entity type EMPLOYEE)
E N D
EER Diagram Prepared BY : Sir Syed Sarmad Ali
Subclasses, Superclasses, Inheritance • • Entity types represent both kinds of entities and sets of entities of that kind that exist in the database (e.g. entity type EMPLOYEE) • • Often an entity type has different subgroups of its entities that need to be represented explicitly in the database because of their significance (e.g. SECRETARY, ENGINNER, MANAGER, TECHNICIAN …) • • The set of entities in each of these subgroups is a subset of the EMPLOYEE entity set (every entity that is a member of one of these subgroups is also an EMPLOYEE entity)
• Each of these subgroups is called a subclass of the EMPLOYEE entity type • • The EMPLOYEE entity type is called the superclass of each of these subclasses • • The relationship between a superclass and any one of its subclasses is called a superclass/subclass or class/subclass or IS-A (IS-AN) relationship (e.g. EMPLOYEE/SECRETARY EMPLOYEE/MANAGER)
Why we need EER modeling? • ER modeling concepts discussed Chapter 3 are sufficient for representing many database schemas for "traditional" database applications, • Design more accurate database schemas that reflect the data properties and constraints more precisely. • Databases for engineering design • Manufacturing • Telecommunications • Complex software systems • Geographic Information Systems (GIs) • More complex requirements • Led to the development of additional semantic data modeling concepts Database Management Systems
Enhanced-ER (EER) Model Concepts • Includes all modeling concepts of basic ER • Additional concepts: subclasses/superclasses, specialization/generalization, categories, attribute inheritance • The resulting model is called the Enhanced-ER or Extended ER (E2R or EER) model • It is used to model applications more completely and accurately with additional semantics • It includes some object-oriented concepts, such as inheritance Database Management Systems
Subclasses and Superclasses (1) • An entity type may have additional meaningful subgroupings of its entities • Example: EMPLOYEE may be further grouped into SECRETARY, ENGINEER, MANAGER, TECHNICIAN, SALARIED_EMPLOYEE, HOURLY_EMPLOYEE,… • Each of these groupings is a subset of EMPLOYEE entities • Each is called a subclass of EMPLOYEE • EMPLOYEE is the superclass for each of these subclasses • These are called superclass/subclass relationships. • Example: EMPLOYEE/SECRETARY, EMPLOYEE/TECHNICIAN Database Management Systems
Subclasses and Superclasses (2) • These are also called IS-A relationships (SECRETARY IS-A EMPLOYEE, TECHNICIAN IS-A EMPLOYEE, …). • Note: An entity that is member of a subclass represents the same real-world entity as some member of the superclass • The Subclass member is the same entity 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 • A member of the superclass can be optionally included as a member of any number of its subclasses • Example: A salaried employee who is also an engineer belongs to the two subclasses ENGINEER and SALARIED_EMPLOYEE • It is not necessary that every entity in a superclass be a member of some subclass Database Management Systems
Example Database Management Systems
Attribute Inheritance in Superclass / Subclass Relationships • An entity that is member of a subclass inherits all attributes of the superclass • It also inherits all relationships of the superclass Database Management Systems
Subclasses and Superclasses • An entity type may have subclasses of its entities • Example: EMPLOYEE may be grouped into: • SECRETARY, ENGINEER, TECHNICIAN, … • Based on the EMPLOYEE’s Job • MANAGER • EMPLOYEEs who are managers • SALARIED_EMPLOYEE, HOURLY_EMPLOYEE • Based on the EMPLOYEE’s method of pay • EMPLOYEE is the superclass for each of these subclasses
Subclasses and Superclasses (2) • Also called IS-A relationships • SECRETARY IS-A EMPLOYEE, TECHNICIAN IS-A EMPLOYEE, …. • An entity cannot exist in the database merely by being a member of a subclass; it must also be a member of the superclass • A member of the superclass can be optionally included as a member of any number of its subclasses
Generalization and Specialization • The process of refining one entity types into subclass types is called specialization. • A top-down process • The process identifying commonalities among different entity types and define their superclass type is called generalization. • A bottom-up process • In real world, a database modeling process is typically mixed.
Condition-Defined Subclasses • Specialization based on conditions of superclass attributes. • Example: High-Pay-Male and High-Paid-Female • Drawing EMPLOYEE d salary100000, Sex=M salary100000, Sex=F High-Pay-Male High-Pay-Female
Discussions • d: means disjoint, each employee can belong to at most one of the subclass. • We do not require total participation: an employee may not be in either class • A special case of condition-defined specialization is when the condition is based on the value of a single attribute • This type specializations is called attribute-defined.
An Attribute-defined Specialization • Doubled line suggests total participation: an employee must be either a male or female. EMPLOYEE Sex d F M Male-EMP Female-EMP
Attribute Inheritance in Superclass / Subclass Relationships • An entity that is member of a subclass inherits • All attributes of the entity as a member of the superclass • All relationships of the entity as a member of the superclass • Example: • SECRETARY inherit the attributes Name, SSN, …, from EMPLOYEE • SECRETARY can have additional attributes specific to secretaries (typing speed, …)
Overlapping Specialization • In an overlapping specialization, indicated by an circled o, an entity in the superclass can belong to more than one subclasses. DEPARTMENT o Has a location in NY Has a location in DC Located-in-DC Located-in-NY
Further Discussions • A specialization can have only one subclass • Example: High-Pay-EMP EMPLOYEE salary100000 High-Pay-EMP
Summary • Four types of specializations • Total (double-lined), disjoint (d) • Partial (single-lined), disjoint (d) • Total (double-lined), overlapping (o) • Partial (single-lined), overlapping (o) • A subclass may have its own (additional) attributes • A superclass may have more than one specialization.
User-Defined Specialization/Generalization • If no condition determines membership, the subclass is called user-defined • Membership in a subclass is determined by the database users by applying an operation to add an entity to the subclass • Membership in the subclass is specified individually for each entity by the user • Example: A HANDICAPPED subclass of EMPLOYEE
Specialization/Generalization Hierarchies, Lattices & Shared Subclasses (1) • A subclass may itself have further subclasses specified on it • forms a hierarchy or a lattice • Hierarchy has a constraint that every subclass has only one superclass (called single inheritance); this is basically a tree structure • In a lattice, a subclass can be subclass of more than one superclass (called multiple inheritance)
Categories (UNION TYPES) • With specialization, all subclasses are of the same type of super-classes. • SECTARY, MANAGER, and HOURLY_EMPLOYEE are all EMPLOYEEs • In some cases, we need to super-classes to be of different entity types • Such a subclass is called a category or UNION TYPE • A category member must exist in at least one of its superclasses
Difference b/w union and shared subclasses • In EER diagrams union types (categories) are • denoted by placing the letter U inside the circle and • the subset symbol on the line connecting the • subclass with the circle • Differences between union types & shared subclasses • An entity of a shared subclass must exist in all superclasses • An entity of a union type must exist in only one superclass • Entities in shared subclasses inherit attributes of all superclasses • Entities in union types inherit attributes of only one superclass
EER diagram notation to represent subclasses and specialization Database Management Systems
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