Why EER
The basic ER model cannot show that some entities form special groups with extra attributes or relationships. The EER model adds the object-oriented ideas of subclass, superclass and inheritance.
Subclass, Superclass and Inheritance
A subclass is a subgroup of the entities of another entity type, the superclass; each subclass entity is also a member of the superclass (SECRETARY is an EMPLOYEE). The subclass inherits all attributes and relationships of the superclass and may add local attributes of its own (typing speed of a secretary). The link is called an IS-A relationship.
Specialization and Generalization
- Specialization is a top-down process of defining subclasses of a superclass based on some distinguishing feature (EMPLOYEE into SECRETARY, ENGINEER, TECHNICIAN by job type).
- Generalization is the reverse bottom-up process of combining entity types with common features into a superclass (CAR and TRUCK into VEHICLE).
Constraints on Specialization and Generalization
- Disjointness:disjoint (d) means an entity can belong to at most one subclass; overlapping (o) means it may belong to several.
- Completeness:total means every superclass entity must belong to some subclass (shown by a double line); partial means some need not.
So there are four combinations: disjoint total, disjoint partial, overlapping total and overlapping partial.
- A predicate-defined subclass is decided by a condition on an attribute (job type = "Engineer"); an attribute-defined specialization uses one attribute for all subclasses; a user-defined subclass is chosen by the user.
Union Type (Category)
A category is a subclass of the union of two or more different superclasses. OWNER may be a PERSON, a COMPANY or a BANK, and an owner entity belongs to just one of them. Unlike multiple inheritance, an entity of a category inherits from only one of its superclasses.
Mapping to Relations
Options are: one table for the superclass and one per subclass (joined by the key); one table per subclass only (when total and disjoint); one single table with a type column; or one table with Boolean type flags for overlapping subclasses.
Definition: Specialization. The top-down process of defining subclasses of an entity type according to some distinguishing characteristic.
Table 1.2: Constraints of specialization
| Constraint | Values | Meaning |
|---|---|---|
| Disjointness | Disjoint, overlapping | One subclass or several |
| Completeness | Total, partial | Every entity in a subclass or not |
| Definition | Predicate, attribute, user | How membership is decided |
Example 1.2: Checking the constraints
Problem: Ten employees have numbers 1 to 10. SECRETARY = {1, 2}, ENGINEER = {3, 4, 5, 6} and TECHNICIAN = {6, 7}. Is the specialization disjoint or overlapping, and total or partial?
Solution:
- Employee 6 is both an ENGINEER and a TECHNICIAN, so the subclasses share a member.
- The specialization is therefore overlapping.
- The union of the subclasses is {1, 2, 3, 4, 5, 6, 7}, that is 7 employees.
- Employees 8, 9 and 10 belong to no subclass, so the specialization is partial.
Result: The specialization is overlapping and partial; 3 of the 10 employees are in no subclass.
emp = set(range(1, 11))
sub = {"SECRETARY": {1, 2}, "ENGINEER": {3, 4, 5, 6},
"TECHNICIAN": {6, 7}}
names = list(sub)
shared = set()
for i in range(len(names)):
for j in range(i + 1, len(names)):
shared |= sub[names[i]] & sub[names[j]]
covered = set().union(*sub.values())
print("Shared members:", shared)
print("Disjoint:", not shared)
print("Covered:", sorted(covered))
print("Total:", covered == emp)
print("Not in any subclass:", sorted(emp - covered))
Output
Shared members: {6}
Disjoint: False
Covered: [1, 2, 3, 4, 5, 6, 7]
Total: False
Not in any subclass: [8, 9, 10]
Common mistakes
- Confusing specialization (top-down) with generalization (bottom-up).
- Treating a category as ordinary multiple inheritance.
- Forgetting that a subclass inherits all attributes and relationships of its superclass.
- Using a total specialization when some entities do not fit any subclass.
Key takeaways
- Subclass inherits attributes and relationships of the superclass (IS-A).
- Constraints: disjoint or overlapping, total or partial.
- Specialization is top-down; generalization is bottom-up.
- A category (union type) has several superclasses but inherits from only one.
Practice questions
- What is inheritance in the EER model?
- What does a total specialization mean?
- What is a union type?
Answers to the practice questions
- A subclass automatically has the attributes and relationships of its superclass.
- Every superclass entity belongs to at least one subclass.
- A subclass of the union of several different superclasses, such as OWNER of PERSON and COMPANY.
Sources
- Official BCA syllabus Advanced Database Systems, course code 25BCA406DS04, Unit I
