Loading learning content...
When we define a MANAGER as a subtype of EMPLOYEE, something powerful happens automatically: every attribute of EMPLOYEE becomes an attribute of MANAGER without explicit declaration. This isn't just syntactic convenience—it's a fundamental semantic statement that managers ARE employees in the fullest sense, possessing all employee characteristics plus their additional managerial ones.
Attribute inheritance is the mechanism that makes this work. It's the core benefit of specialization, eliminating redundancy while preserving semantic completeness. Understanding inheritance deeply is essential for designing EER models that are both semantically correct and practically efficient.
By the end of this page, you will master attribute inheritance in EER modeling: the rules governing what is inherited, how inheritance chains work, the relationship between inheritance and constraints, and the practical implications for both schema design and query formulation. You'll understand inheritance at a level that prevents common errors and enables sophisticated modeling.
Formal Definition:
For entity types E₁ (supertype) and E₂ (subtype) where E₂ specializes E₁:
attrs(E₂) = attrs(E₁) ∪ local_attrs(E₂)
Where:
This means an entity of type E₂ has:
Practical Implications:
Every instance of the subtype is also an instance of the supertype. When you query for all attributes of a MANAGER, you automatically get both manager-specific attributes AND all employee attributes.
You don't 'choose' which attributes to inherit—all supertype attributes are inherited. This is a critical distinction from some object-oriented languages that allow selective inheritance. In EER specialization, if E₂ is a subtype of E₁, E₂ gets everything E₁ has. No exceptions.
Inheritance in EER extends beyond simple attributes. Understanding the complete scope of inheritance is essential for effective modeling.
Inherited Elements:
| Element Type | Inherited? | Details | Example |
|---|---|---|---|
| Simple Attributes | ✓ Yes | All single-valued, atomic attributes | name, salary, hire_date |
| Composite Attributes | ✓ Yes | Complete structures with all components | address (street, city, zip) |
| Multivalued Attributes | ✓ Yes | Sets of values, complete inheritance | phone_numbers, skills |
| Derived Attributes | ✓ Yes | Computations based on other attributes | age (from birth_date), tenure |
| Key Attributes | ✓ Yes | Primary key inherited as primary key of subtype | employee_id → manager_id |
| Relationships | ✓ Yes | All relationship participations | If Employee WORKS_IN Department, Manager does too |
| Constraints | ✓ Yes | All attribute and entity constraints | salary > 0 applies to all subtypes |
Key Inheritance Details:
Primary Key Inheritance: The primary key is particularly important. When MANAGER specializes EMPLOYEE:
Relationship Inheritance: If EMPLOYEE participates in relationships, all subtypes inherit that participation:
When a supertype participates in a relationship, subtypes inherit participation capability. Whether specific constraints (like cardinality or participation requirements) apply to subtypes specifically is context-dependent. We'll explore this nuance in the constraints section.
In multi-level hierarchies, inheritance creates chains where attributes propagate through multiple levels. Understanding these chains is critical for querying and constraint design.
The Transitive Property:
If B specializes A, and C specializes B, then:
Mathematically: attrs(C) = attrs(A) ∪ local_attrs(B) ∪ local_attrs(C)
123456789101112131415161718192021222324
-- Multi-Level Inheritance Example PERSON (Level 0)├── ssn PK├── name├── birth_date└── address └─→ EMPLOYEE (Level 1) ├── [Inherited: ssn, name, birth_date, address] ├── emp_id (alternate key) ├── hire_date └── salary └─→ MANAGER (Level 2) ├── [Inherited: ssn, name, birth_date, address, emp_id, hire_date, salary] ├── department └── budget └─→ EXECUTIVE (Level 3) ├── [Inherited: ssn, name, birth_date, address, emp_id, │ hire_date, salary, department, budget] ├── stock_options └── board_seat -- EXECUTIVE has 11 attributes:-- 4 from PERSON + 3 from EMPLOYEE + 2 from MANAGER + 2 local = 11 totalAttribute Accumulation Pattern:
As you move down the hierarchy, entities accumulate more attributes. This has practical implications:
Leaf entities have the most attributes — Entities at the deepest levels have inherited attributes from all ancestors plus their own local attributes.
Higher entities have fewer attributes but cover more entities — PERSON is simpler but includes everyone; EXECUTIVE is complex but includes few.
Query design depends on level — Querying at higher levels returns more rows with fewer columns; querying at lower levels returns fewer rows with more columns.
Schema mapping affects performance — In relational mapping, multi-level hierarchies may require multiple joins (class table inheritance) or wide tables with nulls (single table inheritance).
When modeling, expect leaf subtypes to have significantly more attributes than the root supertype. If a deep subtype has few attributes, consider whether the hierarchy is correctly structured—perhaps some subtypes don't add enough distinction to warrant separate types.
Just as attributes are inherited, constraints defined on supertypes apply to all subtypes. This inheritance of constraints is logically necessary—if a manager IS-A employee, then constraints on employees must hold for managers.
Types of Inherited Constraints:
Constraint Refinement (Strengthening):
While subtypes inherit all supertype constraints, they can add stricter constraints for local attributes or even for inherited attributes:
EMPLOYEE: salary > 0
MANAGER: salary > 50000 (stricter than inherited)
EXECUTIVE: salary > 150000 (stricter still)
This is valid because:
Constraint Weakening is INVALID:
Subtypes cannot weaken inherited constraints:
EMPLOYEE: salary > 30000
MANAGER: salary > 20000 ← INVALID! Violates Liskov Substitution
This would allow managers with salaries that violate employee constraints, breaking the IS-A semantics.
Constraints on subtypes must be compatible with (same as or stricter than) supertype constraints. A query expecting employee data must work correctly when given manager data. If managers could violate employee constraints, this substitutability breaks down.
Inheritance has profound implications for how we query specialization hierarchies. Understanding these implications enables writing efficient, correct queries.
Polymorphic Queries:
A query against a supertype automatically includes all subtype instances:
1234567891011121314151617181920212223
-- Polymorphic Query: Returns ALL employees (including managers, engineers, etc.)SELECT emp_id, name, salary FROM EMPLOYEE; -- This single query returns:-- • Regular employees-- • Managers (with their inherited emp_id, name, salary)-- • Engineers (with their inherited emp_id, name, salary)-- • All other employee subtypes -- Subtype-Specific Query: Returns only managersSELECT emp_id, name, salary, department, budgetFROM MANAGER; -- Accessing local + inherited attributesSELECT e.emp_id, -- inherited from EMPLOYEE e.name, -- inherited from EMPLOYEE e.salary, -- inherited from EMPLOYEE m.department, -- local to MANAGER m.budget -- local to MANAGERFROM MANAGER m-- Depending on physical schema, may need join to EMPLOYEE eQuery Pattern Strategies:
The actual SQL syntax for these queries depends on how the EER model is mapped to relational tables. Single table inheritance gives simple queries; class table inheritance may require joins to access all attributes. We'll explore these mapping strategies in detail in the ER-to-Relational Mapping chapter.
Inheritance affects not just queries but also data modification operations. Understanding these implications prevents subtle bugs and data integrity issues.
Insert Operations:
When inserting a subtype entity, you must provide values for:
-- Inserting a MANAGER requires all EMPLOYEE attributes plus MANAGER attributes
INSERT INTO MANAGER (emp_id, name, email, salary, hire_date, -- inherited
department, budget, direct_reports) -- local
VALUES (101, 'Alice Smith', 'alice@corp.com', 95000, '2023-01-15',
'Engineering', 500000, 8);
Update Operations:
Updating inherited attributes on a subtype affects the underlying supertype data:
12345678910111213141516171819202122
-- Update inherited attribute via subtypeUPDATE MANAGER SET salary = 105000 WHERE emp_id = 101; -- This manager (emp_id=101) now has salary=105000-- When queried as EMPLOYEE, they also show salary=105000-- Because MANAGER and EMPLOYEE share identity -- Update local attribute (only affects subtype)UPDATE MANAGER SET budget = 600000 WHERE emp_id = 101; -- This only affects manager-specific data -- Important: What happens with polymorphic update?UPDATE EMPLOYEE SET salary = salary * 1.05; -- 5% raise for all -- This raises salary for:-- • Regular employees-- • All managers (including the one with emp_id=101)-- • All engineers-- • All other employee subtypes -- The manager with emp_id=101 now has salary = 105000 * 1.05 = 110250Delete Operations:
Deleting an entity has implications across the hierarchy:
-- Delete a manager
DELETE FROM MANAGER WHERE emp_id = 101;
-- Question: Is emp_id=101 still an employee?
This depends on modeling semantics:
Interpretation A (Type Change): Deleting from MANAGER removes manager-specific data but the person remains an employee. They're now a 'regular' employee without manager attributes.
Interpretation B (Complete Removal): Deleting from MANAGER removes the entity entirely from the hierarchy—they're no longer an employee at all.
The correct interpretation depends on your domain and is typically enforced at the application level or via careful trigger design.
EER models don't prescribe delete semantics. You must decide: Does deleting from a subtype remove subtype-specific data only (demotion) or remove the entity entirely (cascade)? Document this decision clearly and implement it consistently.
Let's examine common patterns where inheritance provides significant modeling value.
Pattern: Multiple entity types share common attributes and are unified under a common supertype.
Example: E-commerce platform with multiple product types
PRODUCT (Base)
├── product_id PK
├── name
├── description
├── price
├── category_id FK
└── created_at
PHYSICAL_PRODUCT (inherits all PRODUCT attributes)
├── weight
├── dimensions
├── shipping_class
└── warehouse_location
DIGITAL_PRODUCT (inherits all PRODUCT attributes)
├── file_size
├── download_url
├── license_type
└── version
SUBSCRIPTION_PRODUCT (inherits all PRODUCT attributes)
├── billing_cycle
├── trial_period
├── auto_renew
└── tier_level
Benefits:
This page has provided a comprehensive understanding of attribute inheritance in EER modeling. Let's consolidate the key insights:
What's Next:
Having understood inheritance of supertype attributes, we now turn to local attributes—the attributes defined specifically for subtypes that distinguish them from siblings and add their unique characteristics to the model.
You now have a deep understanding of attribute inheritance—the mechanism that makes specialization powerful. You can trace inheritance chains, understand constraint inheritance, write correct queries at any hierarchy level, and handle data modifications appropriately. This knowledge is essential for effective EER modeling.