Relational Model
The Enhanced Entity-Relationship (EER) Model
Copyright By PowCoder代写 加微信 powcoder
Chapter 4 Outline
Subclasses, Superclasses, and Inheritance
Specialization and Generalization
Constraints and Characteristics of Specialization and Generalization Hierarchies
Modeling of UNION Types Using Categories
Subclasses and Superclasses
TECHNICIAN
SALARIED_EMPLOYEE
HOURLY_EMPLOYEE
Every entity that is a member of one of these subgroupings is also an employee
Superclasses: EMPLOYEE
Subclasses: SECRETARY, ENGINEER,
TECHNICIAN,
SALARIED_EMPLOYEE, HOURLY_EMPLOYEE
An entity type may have additional meaningful subgroupings of its entities
EER Notation
Specific attributes
Generalization
Specialization
Why class/subclass relationships and specializations
Certain attributes may apply to some but not all entities of the superclass.
A subclass is defined in order to group the entities to which these attributes apply.
The members of the subclass may still share the majority of their attributes with the other members of the superclass.
All employees have names, SSN, Birthdates, Addresses
Secretaries also have Typing Speed
Engineers also have EngineerType
Technicians also have Tgrade
Attribute Inheritance
TECHNICIAN
TypingSpeed
Fname, Lname, SSN, Addr TypingSpeed
TECHNICIAN
Fname, Lname, SSN, Addr, TGrade
Fname, Lname, SSN, Addr, EngType
Fname, Lname, SSN, Addr
Why class/subclass relationships and specializations
Some relationship types may be participated in only by entities that are members of the subclass.
All Employees work for Departments
Managers are assigned to Projects
Hourly Employees belong to Trade Unions
Relationship Inheritance
EMPLOYEE: WORKS
SECRETARY: WORKS
TECHNICIAN: WORKS
ENGINEER: WORKS
MANAGER: WORKS, MANAGES
SALARIED_EMP: WORKS
HOURLY_EMP: WORKS, BELONGS_TO
TECHNICIAN
SALARIED_EMP
HOURLY_EMP
TRADE_UNION
DEPARTMENT
BELONGS_TO
TypingSpeed
Specialized Instances
A superclass/subclass relationship may resemble a 1:1 relationship at the instance level.
The main difference is that
In a 1:1 relationship two distinct entities are related,
In a superclass/subclass relationship the entity in the subclass is the same real-world entity as the entity in the superclass but playing a specialized role.
Specialization and Generalization Hierarchies and Lattices
Specialization hierarchy
Every subclass participates as a subclass in only one class/subclass relationship
tree structure or strict hierarchy
Specialization lattice
Subclass can be a subclass in more than one class/subclass relationship
ER (Chen) Notation
Specialization and Generalization Hierarchies and Lattices (cont’d.)
Multiple inheritance
Subclass with more than one superclass
If attribute (or relationship) originating in the same superclass inherited more than once via different paths in lattice
Included only once in shared subclass
Single inheritance
Some models and languages limited to single inheritance
Some insertion and deletion rules
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 applicable subclasses.
Inserting an entity in a superclass of a total specialization implies that the entity is mandatorily inserted in at least one of the subclasses of the specialization.
Constraints on Specialization/Generalization
Disjointness vs. Overlap Constraints
A total specialization vs. a partial specialization
Specialization/Generalization hierarchies and lattices
Utilizing specialization and generalization in Conceptual Data Modeling
Disjointness Constraint
Disjointness(d) constraint specifies that the subclasses of the specialization must be disjointed
an entity can be a member of at most one of the subclasses of the specialization
In EER diagram, d in the circle stands for disjoint.
Disjoint Subclasses
TECHNICIAN
SALARIED_EMP
HOURLY_EMP
Disjoint subclasses
Disjoint subclasses
Overlap Constraint
Overlap(o) specifies that the subclasses are not constrained to be disjoint
the same (real-world) entity may be a member of more than one subclass of the specialization.
Default constraint
Displayed by placing an o in the circle.
Completeness constraint
Completeness constraint may be total or partial.
A total specialization constraint specifies that every entity in the superclass must be a member of some subclass in the specialization.
Represented by a double line connecting the superclass to the circle.
Completeness constraint (cont.)
A partial specialization allows an entity not to belong to any of the subclasses, using a single line in EER.
If some EMPLOYEE entities, like sales representatives, do not belong to any of the subclasses {SECRETARY, ENGINEER, TECHNICIAN}, then the specialization is partial.
Represented by a single line connecting the superclass to the circle.
Four Possible Constraints
The disjointness and completeness constraints are independent.
There are four possible constraints on specialization:
Disjoint, total (one and only one)
Disjoint, partial (zero to one)
Overlapping, total (one to many)
Overlapping, partial (zero to many)
UNION Types Using Categories
Union type or a category
Represents a single superclass/subclass relationship with more than one superclass
Subclass represents a collection of objects that is a subset of the UNION of distinct entity types
Attribute inheritance works more selectively
Category can be total or partial
Some modeling methodologies do not have union types
UNION Types (Category) Example:
ER (Chen) Notation
Example of Other Notation
Representing specialization and generalization in UML class diagrams
Base class
Root superclass
Leaf classes
Subclasses (leaf nodes)
UML Notation
EERD Checklist
Making a good ERD, better!
EER Diagram Checklist
Entities – Nouns
People, Departments, Roles, Products, Inputs, Outputs
Relationships – Verbs
Actions, associations, connections, specializations, generalizations, aggregations
Is-a, has-a
EER Diagram Checklist
Specializations only
If attribute or relationship is unique
Generalizations only
If attributes or relationships are common
Example Spotify EER Diagram:
/docProps/thumbnail.jpeg
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com