Advanced Data Modelling (EER)
Connection traps (fan and chasm), supertypes/subtypes, inheritance, discriminators, and specialization constraints.
Contents
- Explain the relevance of data modelling to the relational model
- Explain and develop Enhanced (Extended) Entity Relationship modelling
- Describe specialization / generalization hierarchies
ER modelling and the design process
ER modelling is a very effective tool for standard relational database tasks. It provides semantic information, but that is not always sufficient — it is less adapted to more complex semantics (e.g. “a pilot is a kind of employee with extra attributes”). This is why the Enhanced ER model was developed.
The database design process
ER/EER diagrams belong to the conceptual stage; they are then mapped to relations (logical) and finally to tables, indexes and storage (physical).
Problems with ER models: connection traps
When designing a conceptual model, problems called connection traps can arise, usually because the meaning of certain relationships was misinterpreted. The two main types:
The model represents a relationship between entity types, but the pathway between certain entity occurrences is ambiguous.
The model suggests a relationship exists between entity types, but a pathway does not exist between certain entity occurrences.
Fan trap — example and fix
Two 1:* relationships fan out from the same entity (Division):
- One or more staff are located in exactly one division.
- One division operates one or more branches.
Question: At which branch office does staff number SG37 work?
Looking at the occurrences (semantic net): SG37 is linked to division D1, and D1 operates both B003 and B007. We cannot tell which one — the pathway is ambiguous.
| Staff | Division | Branches of that division |
|---|---|---|
| SG37 | D1 | B003, B007 → ambiguous |
| SA9 | D1 | B003, B007 → ambiguous |
| SL21 | D2 | B005 |
Restructuring to remove the fan trap
Re-order the entities so the path is a chain: Division —Operates→ Branch —Has→ Staff.
Now each staff member links to exactly one branch, and each branch to exactly one division. The semantic net shows unambiguously: SG37 works at branch B003.
Look for an entity with two or more 1:* relationships fanning out from it, where you actually need to navigate from one “many” side to the other.
Chasm trap — example and fix
- A branch has one or more staff; each staff member belongs to exactly one branch.
- A staff member oversees zero or more properties; a property is overseen by zero or one staff member (optional participation).
Question: At which branch office is property PA14 available?
PA14 is not yet assigned to any staff member, so there is no path from PA14 through Staff to a Branch. We can’t answer the question — this is the “chasm”.
Restructuring to remove the chasm trap
Add the missing relationship Offers directly between Branch (1..1) and PropertyForRent (1..*):
Now every property is linked directly to its branch, whether or not a staff member oversees it.
Look for a path that passes through a relationship with optional (0..) participation. Occurrences that don’t participate break the path.
The Enhanced (Extended) ER model
The Extended Entity Relationship Model (EERM) is the result of adding more semantic constructs to the original ER model. A diagram using this model is called an EER diagram (EERD).
The main new constructs: supertypes/subtypes, specialization hierarchies, inheritance, subtype discriminators, disjoint/overlapping and completeness constraints.
Entity supertypes and subtypes
A generic entity type related to one or more subtypes. Contains the common characteristics.
Contains the unique characteristics of each subtype.
Why? — nulls created by unique attributes
Imagine one EMPLOYEE table for all employees, including pilots. Pilot-only columns (EMP_LICENSE, EMP_RATINGS, EMP_MED_TYPE) are NULL for every non-pilot:
| EMP_NUM | EMP_LNAME | EMP_LICENSE | EMP_RATINGS | EMP_MED_TYPE |
|---|---|---|---|---|
| 100 | Kolmycz | |||
| 101 | Lewis | ATP | SEL/MEL/Instr/CFII | 1 |
| 102 | Vandam | |||
| 104 | Lange | ATP | SEL/MEL/Instr | 1 |
| … | … | … | … | … |
Rob & Coronel, Fig 6.1 (abridged). Splitting PILOT out as a subtype removes these nulls.
Specialization hierarchy
- Depicts the arrangement of higher-level supertypes (parent entities) and lower-level subtypes (child entities).
- Relationships are described as “IS-A” relationships (a pilot IS-A employee).
- A subtype exists only within the context of its supertype, and every subtype has only one supertype it is directly related to.
- There can be many levels of supertype/subtype relationships.
Based on Rob & Coronel Fig 6.2. Shared attributes live in the supertype; unique attributes live in subtypes. “d” = disjoint; EMP_TYPE is the subtype discriminator. Double line under the circle (not shown) would mean total completeness.
A specialization hierarchy lets you:
- support attribute inheritance;
- define a special supertype attribute called the subtype discriminator;
- define disjoint/overlapping constraints and complete/partial constraints.
Inheritance
- Enables an entity subtype to inherit the attributes and relationships of the supertype (e.g. PILOT inherits EMP_LNAME and EMPLOYEE’s has relationship with DEPENDENT).
- All entity subtypes inherit their primary key from their supertype (PILOT’s PK is EMP_NUM, which is also an FK to EMPLOYEE).
- At implementation level, a supertype and each of its subtypes maintain a 1:1 relationship.
| EMPLOYEE | ||
|---|---|---|
| EMP_NUM | EMP_LNAME | EMP_TYPE |
| 100 | Kolmycz | A |
| 101 | Lewis | P |
| 104 | Lange | P |
| 105 | Williams | P |
| PILOT | ||
|---|---|---|
| EMP_NUM | PIL_LICENSE | PIL_MED_TYPE |
| 101 | ATP | 1 |
| 104 | ATP | 1 |
| 105 | COM | 2 |
Rob & Coronel Fig 6.3 (abridged): the EMPLOYEE–PILOT supertype/subtype relationship. Each pilot row matches exactly one employee row.
Subtype discriminator
The attribute in the supertype that determines to which subtype each supertype occurrence is related (e.g. EMP_TYPE = "P" → PILOT, "M" → MECHANIC, "A" → ACCOUNTANT).
The default comparison condition for the discriminator is equality.
Disjoint and overlapping constraints
Disjoint (d)
Also called non-overlapping. Each supertype occurrence belongs to at most one subtype — subtypes contain a unique subset of the supertype entity set.
e.g. an employee is a pilot or a mechanic or an accountant.
Overlapping (o)
A supertype occurrence may belong to more than one subtype — subtypes contain non-unique subsets.
e.g. a PERSON can be both an EMPLOYEE and a STUDENT; an employee can be both a PROFESSOR and an ADMINISTRATOR.
In Rob & Coronel Fig 6.4, PERSON →(o)→ EMPLOYEE, STUDENT; EMPLOYEE →(o)→ ADMINISTRATOR, PROFESSOR; STUDENT →(d)→ GRADUATE, UNDERGRAD.
With overlapping subtypes a single discriminator value can’t work, so you use one Y/N discriminator per subtype:
| PROFESSOR | ADMINISTRATOR | Comment |
|---|---|---|
| "Y" | "N" | The Employee is a member of the Professor subtype. |
| "N" | "Y" | The Employee is a member of the Administrator subtype. |
| "Y" | "Y" | The Employee is both a Professor and an Administrator. |
Table 6.1 — Discriminator attributes with overlapping subtypes.
Completeness constraint
Specifies whether each supertype occurrence must also be a member of at least one subtype.
- Partial completeness (single line): not every supertype occurrence must belong to a subtype.
- Total completeness (double line): every supertype occurrence must belong to at least one subtype.
| Type | Disjoint constraint | Overlapping constraint |
|---|---|---|
| Partial | Supertype has optional subtypes. Subtype discriminator can be null. Subtype sets are unique. | Supertype has optional subtypes. Subtype discriminators can be null. Subtype sets are not unique. |
| Total | Every supertype occurrence is a member of (at least one) subtype. Subtype discriminator cannot be null. Subtype sets are unique. | Every supertype occurrence is a member of (at least one) subtype. Subtype discriminators cannot be null. Subtype sets are not unique. |
Table 6.2 — Specialization hierarchy constraint scenarios. Memorize this grid — it combines both constraints.
Specialization vs generalization
Specialization ↓
Top-down process: start from a higher-level supertype and identify lower-level, more specific subtypes.
Based on grouping the unique characteristics and relationships of the subtypes.
Generalization ↑
Bottom-up process: start from lower-level subtypes and identify a higher-level, more generic supertype.
Based on grouping the common characteristics and relationships of the subtypes.