The basic ER model you have seen so far (entities, attributes, relationships and weak entities) is enough for many small designs. But real organisations are messier. A company has employees, and some of those employees are engineers with a skill set, some are managers with a team, and some are both. A university has students and professors who are all, in some sense, "people". And sometimes you need to say something about a relationship itself, not just about the entities it connects.
To handle these situations, the ER model was extended with a few extra ideas. The extended version is usually called the Enhanced (or Extended) ER model, or EER model. In this chapter we cover its three most important additions:
Specialization — splitting an entity into more specific sub-groups (top-down)
Generalization — combining similar entities into a more general one (bottom-up)
Aggregation — treating a relationship as if it were an entity, so that it can take part in another relationship
We will build on the notation from the earlier chapters ER Model, Relationships, Cardinality & Participation and Weak Entities.
Superclass, Subclass and the IS-A Relationship
Both specialization and generalization produce the same structure: a superclass (the general entity) and one or more subclasses (the specific entities).
A subclass is an entity set whose every member is also a member of another entity set, called its superclass. The link between them is called an IS-A relationship.
For example, every Engineer IS-A Employee, and every Manager IS-A Employee. We read the link upwards: "an engineer is an employee".
Two important rules follow from this:
An entity in a subclass is the same real-world thing as an entity in the superclass. Engineer Divya and Employee Divya are not two people; they are one person seen at two levels of detail. So a subclass entity cannot exist without the corresponding superclass entity.
Attribute inheritance: a subclass automatically has all the attributes of its superclass (and takes part in all the superclass's relationships). It then adds its own local attributes and relationships.
In ER diagrams, IS-A is usually drawn as a triangle labelled ISA (Korth style) or as a circle with a letter d / o (Elmasri–Navathe style). In text form we will draw it like this:
+--------------------+
| EMPLOYEE | emp_id (key), name, salary
+--------------------+
|
[ISA]
+------------+-------------+
| | |
+----------+ +-----------+ +-----------+
| ENGINEER | | MANAGER | | SECRETARY |
+----------+ +-----------+ +-----------+
skill team_size typing_speed
An engineer therefore has emp_id, name, salary (inherited) and skill (local). Notice that the subclasses do not repeat emp_id as a separate key — they are identified by the superclass key.
Specialization (Top-Down)
Specialization is the process of defining a set of subclasses of an entity, based on some distinguishing characteristic of its entities. It is a top-down design step: you start with a general entity and break it into more specific ones.
You start with EMPLOYEE and notice that different kinds of employees need different data:
Engineers need a
skill.Managers need a
team_size, and only managers take part in a relationship Approves with LEAVE_REQUEST.Secretaries need a
typing_speed.
Why not just keep one big entity?
You could give EMPLOYEE all of the attributes skill, team_size and typing_speed. But then:
Most employees would have NULL in most of those attributes (a secretary has no team size).
The diagram no longer says who is allowed to have which attribute, or who can approve leave. That rule lives only in someone's head.
Specialization makes these facts part of the design: only managers approve leave becomes visible in the diagram because the Approves relationship is attached to MANAGER, not to EMPLOYEE.
Two reasons to specialize
Some attributes apply only to a subset of the entities (local attributes).
Some relationships apply only to a subset of the entities (local relationships).
If neither reason applies, a subclass adds nothing and you probably don't need it.
Generalization (Bottom-Up)
Generalization is the reverse process: you identify common features of several entity sets and combine them into a single, higher-level entity set (the superclass). It is a bottom-up design step.
Suppose a transport department first models two separate entities:
CAR (vehicle_no, reg_date, price, seating_capacity)
TRUCK (vehicle_no, reg_date, price, max_load_tonnes)
They clearly share vehicle_no, reg_date and price. We generalize them into VEHICLE:
+-------------------------------+
| VEHICLE | vehicle_no (key), reg_date, price
+-------------------------------+
|
[ISA]
+---------+---------+
| |
+---------+ +---------+
| CAR | | TRUCK |
+---------+ +---------+
seating_capacity max_load_tonnes
Now a relationship such as Insured_by can be attached once, to VEHICLE, instead of twice.
Specialization vs generalization — same picture, different direction
The final diagram looks the same either way. The difference is only in how the designer got there.
Point | Specialization | Generalization |
|---|---|---|
Direction | Top-down | Bottom-up |
Starts from | One general entity | Several specific entities |
Produces | New lower-level entities (subclasses) | A new higher-level entity (superclass) |
Main motivation | Some members need extra attributes or relationships | Several entities share attributes; remove repetition |
Example | EMPLOYEE → ENGINEER, MANAGER | CAR, TRUCK → VEHICLE |
Result | Superclass + subclasses linked by IS-A, with attribute inheritance | Same structure as specialization |
A handy memory trick: specialization splits, generalization groups.
Constraints on Specialization and Generalization
Just saying "EMPLOYEE has subclasses" is not enough. Two questions must be answered for every IS-A hierarchy, and exam questions love them.
1. Disjointness constraint: can an entity be in more than one subclass?
Disjoint (marked d): an entity can belong to at most one subclass. Example: a VEHICLE is either a CAR or a TRUCK, never both.
Overlapping (marked o): an entity can belong to several subclasses at once. Example: an employee can be both an ENGINEER and a MANAGER (an engineering manager who still has a technical skill).
2. Completeness (participation) constraint: must every entity be in some subclass?
Total (double line from superclass): every superclass entity must belong to at least one subclass. Example: every ACCOUNT in a bank is either a SAVINGS or a CURRENT account; there is no "plain account".
Partial (single line): some superclass entities may belong to no subclass. Example: an EMPLOYEE who is neither engineer, manager nor secretary (say, a driver) is still a valid employee.
The two constraints are independent, so there are four combinations:
Combination | Meaning | Example |
|---|---|---|
Disjoint, total | Exactly one subclass for every entity | ACCOUNT → SAVINGS / CURRENT |
Disjoint, partial | At most one subclass | EMPLOYEE → ENGINEER / MANAGER / SECRETARY (by job type; drivers are in none) |
Overlapping, total | At least one, maybe several | PERSON (in a university database) → STUDENT / STAFF; everyone stored is at least one of these, a PhD scholar working as staff is both |
Overlapping, partial | Zero, one or several | EMPLOYEE → ENGINEER / MANAGER (by role; some employees have neither role) |
Rule of thumb: generalization is usually total, because the superclass was built only from the subclasses you already had. Specialization is often partial.
Condition-defined vs user-defined subclasses
How does the system know which subclass an entity belongs to?
Condition-defined (predicate-defined / attribute-defined): membership is decided by a condition on a superclass attribute. If EMPLOYEE has an attribute
job_type, thenjob_type = 'Engineer'decides ENGINEER membership. The attribute is called the defining attribute. Because one attribute has only one value, a specialization defined on a single-valued attribute is automatically disjoint.User-defined: there is no rule; a user (or application) puts each entity into its subclass explicitly. "Which employees are on the sports committee?" is user-defined.
What happens on insert and delete?
These constraints have practical effects:
Deleting an entity from the superclass deletes it from every subclass (the subclass entity cannot exist alone).
With total specialization, inserting a superclass entity forces you to insert it into at least one subclass too.
With a disjoint condition-defined specialization, inserting an entity places it in exactly the subclass its defining attribute points to.
Hierarchies, Lattices and Multiple Inheritance
A subclass can itself be specialized further, giving a multi-level structure:
PERSON
|
[ISA]
+------+------+
| |
EMPLOYEE STUDENT
| |
[ISA] [ISA]
+--+--+ +--+---------+
| | | |
FACULTY STAFF UG_STUDENT PG_STUDENT
In a specialization hierarchy, every subclass has exactly one superclass (a tree).
In a specialization lattice, a subclass can have more than one superclass. Such a subclass is called a shared subclass, and it inherits attributes from all its superclasses — this is multiple inheritance.
Classic example: a TEACHING_ASSISTANT is both an EMPLOYEE (gets a salary) and a STUDENT (has a roll number and CGPA). Note that a shared subclass is an intersection: a TA must be in both superclasses.
Some textbooks (Elmasri & Navathe) also describe a category or union type, which is the opposite idea: a subclass whose members come from any one of several unrelated superclasses. For example, a vehicle OWNER may be a PERSON, a BANK or a COMPANY. Most university syllabi only mention it briefly.
Aggregation
Aggregation solves a very specific limitation of the basic ER model:
In the ER model, a relationship can connect only entity sets. It cannot connect a relationship to another entity or relationship.
Aggregation is an abstraction in which a relationship set, together with the entity sets it connects, is treated as a single higher-level entity set. That higher-level entity can then participate in other relationships.
The problem
In a college, students work on projects. A student may work on several projects, and a project has several students, so Works_on is an M:N relationship between STUDENT and PROJECT, with an attribute hours.
Now a new rule arrives: each (student, project) assignment is monitored by one professor. Note what is being monitored: not the student alone (a student may be on two projects with two different monitors) and not the project alone (different students on the same project can have different monitors). It is the assignment — the Works_on pairing — that is monitored.
Attempt 1: a ternary relationship
We could create a ternary relationship Monitors(STUDENT, PROJECT, PROFESSOR). This has two problems:
It loses a constraint. Nothing stops us from recording "Prof. Rao monitors Asha on Project 7" even when Asha doesn't work on Project 7 at all. The rule "you can only monitor an existing assignment" is not expressed.
It duplicates information. Every (student, project) pair now appears in both Works_on and Monitors.
Attempt 2: aggregation
We draw a box around Works_on and its two entities, and treat the whole box as one entity. Then Monitors is an ordinary binary relationship between that box and PROFESSOR:
+-------------------------------------------------------+
| |
| +---------+ <Works_on> +---------+ |
| | STUDENT |-----( hours )---------| PROJECT | |
| +---------+ +---------+ |
| |
+---------------------------+---------------------------+
|
<Monitors>
|
+-------------+
| PROFESSOR |
+-------------+
Now the diagram says exactly what we mean: a professor monitors a Works_on instance. A monitor can only be attached to an assignment that already exists, and the (student, project) pair is stored once.
When should you use aggregation?
Ask yourself: "Am I describing a fact about an entity, or a fact about a relationship between entities?" If the new fact (monitor, approval, loan, sponsorship) is about a relationship instance, and that fact connects to yet another entity, aggregation is the right tool.
Other common examples:
An EMPLOYEE Works_on a PROJECT, and that assignment Uses some MACHINERY.
A CUSTOMER Borrows a LOAN at a BRANCH, and each loan arrangement is Approved_by a LOAN_OFFICER.
How an aggregation becomes tables (the monitor table points to the Works_on table, not to Student and Project separately) is shown in the next chapter, Converting ER Diagrams to Tables.
Generalization/Specialization vs Aggregation
Point | Generalization / Specialization | Aggregation |
|---|---|---|
Relationship type | IS-A (an engineer is an employee) | HAS-A / part-of (an assignment has a student and a project) |
What it groups | Entity sets into a class hierarchy | A relationship + its entity sets into one abstract entity |
Inheritance | Subclasses inherit attributes and relationships | No inheritance |
Problem solved | Different members need different attributes/relationships; common features repeated | Need a relationship that involves another relationship |
Common Mistakes
Giving subclasses their own key. ENGINEER does not need an
engineer_id; it is identified by the superclass keyemp_id.Specializing with no reason. If a subclass has no local attributes and no local relationships, it is just a value of an attribute (for example
job_type).Mixing up the two constraints. Disjoint/overlapping is about "how many subclasses at most"; total/partial is about "at least one or not". Answer both separately.
Using a ternary relationship where aggregation is needed. If the third entity relates to an existing pair, use aggregation.
Confusing aggregation (EER) with aggregate functions (SQL). They share a name and nothing else.
SUM,COUNTetc. are covered in the SQL tutorial.
Interview and Exam Questions
What is the difference between specialization and generalization?
Both create a superclass–subclass (IS-A) structure. Specialization is top-down: start from one entity and define subclasses for subsets that need extra attributes or relationships. Generalization is bottom-up: start from several entities and extract their common features into a superclass.
What is attribute inheritance?
A subclass entity automatically has all attributes of its superclass and participates in all the superclass's relationships, in addition to its own local attributes and relationships.
Explain disjoint vs overlapping and total vs partial with one example each.
Disjoint: an entity is in at most one subclass (a vehicle is a car or a truck). Overlapping: it may be in several (an employee can be an engineer and a manager). Total: every superclass entity is in some subclass (every account is savings or current). Partial: some are in none (a driver is an employee but not an engineer, manager or secretary).
Why is aggregation needed? Why not just use a ternary relationship?
The ER model cannot connect a relationship to another relationship. A ternary relationship would allow combinations that don't exist in the underlying binary relationship (monitoring a student on a project they don't work on) and repeats data. Aggregation treats the relationship as an entity so the new relationship applies only to existing relationship instances.
Is a condition-defined specialization on a single-valued attribute disjoint or overlapping?
Disjoint, because a single-valued defining attribute can have only one value per entity, so the entity satisfies only one subclass condition.
What is a shared subclass?
A subclass with more than one superclass in a specialization lattice, for example TEACHING_ASSISTANT under both EMPLOYEE and STUDENT. It inherits attributes from all its superclasses (multiple inheritance).
Summary
The EER model adds superclass/subclass (IS-A) structures and aggregation to the basic ER model.
Specialization (top-down) splits an entity into subclasses; generalization (bottom-up) groups entities into a superclass. Both give the same IS-A structure with attribute inheritance.
Every IS-A structure has a disjointness constraint (disjoint / overlapping) and a completeness constraint (total / partial).
Subclasses can be condition-defined (by a defining attribute) or user-defined. Hierarchies have one superclass per subclass; lattices allow shared subclasses.
Aggregation treats a relationship (with its entities) as a higher-level entity so it can take part in another relationship.
Next, in Converting ER Diagrams to Tables, we will turn everything from the ER chapters — including specialization and aggregation — into real relational tables.