☰ Chapters
Week 2 · Advanced Data Modelling
CT004-3.5-3 Advanced Database Systems · Week 2

Advanced Data Modelling (EER)

Connection traps (fan and chasm), supertypes/subtypes, inheritance, discriminators, and specialization constraints.

Contents
    Learning outcomes

    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

    Requirements Definition Data Analysis Conceptual data model Logical data model Physical Design Database

    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:

    Fan trap

    The model represents a relationship between entity types, but the pathway between certain entity occurrences is ambiguous.

    Chasm trap

    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):

    Staff Division Branch ◀ HasOperates ▶ 1..*1..1 1..11..*

    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.

    StaffDivisionBranches of that division
    SG37D1B003, B007 → ambiguous
    SA9D1B003, B007 → ambiguous
    SL21D2B005

    Restructuring to remove the fan trap

    Re-order the entities so the path is a chain: Division —Operates→ Branch —Has→ Staff.

    Division Branch Staff Operates ▶Has ▶ 1..11..* 1..11..*

    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.

    How to spot a fan trap

    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

    Branch Staff PropertyForRent Has ▶Oversees ▶ 1..11..* 0..10..*

    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..*):

    Branch Staff PropertyForRent Has ▶Oversees ▶ Offers ▶ (new) 1..11..*

    Now every property is linked directly to its branch, whether or not a staff member oversees it.

    How to spot a chasm trap

    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

    Definition

    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

    Entity supertype

    A generic entity type related to one or more subtypes. Contains the common characteristics.

    Entity subtype

    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_NUMEMP_LNAMEEMP_LICENSEEMP_RATINGSEMP_MED_TYPE
    100Kolmycz
    101LewisATPSEL/MEL/Instr/CFII1
    102Vandam
    104LangeATPSEL/MEL/Instr1
    ……………

    Rob & Coronel, Fig 6.1 (abridged). Splitting PILOT out as a subtype removes these nulls.

    Specialization hierarchy

    EMPLOYEE PK EMP_NUM EMP_LNAME, EMP_FNAMEEMP_HIRE_DATEEMP_TYPE d EMP_TYPE "P""M""A" PILOT PK,FK1 EMP_NUMPIL_LICENSE, …PIL_MED_TYPE MECHANIC PK,FK1 EMP_NUMMEC_TITLEMEC_CERT ACCOUNTANT PK,FK1 EMP_NUMACT_TITLEACT_CPA_DATE

    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:

    Inheritance

    EMPLOYEE
    EMP_NUMEMP_LNAMEEMP_TYPE
    100KolmyczA
    101LewisP
    104LangeP
    105WilliamsP
    PILOT
    EMP_NUMPIL_LICENSEPIL_MED_TYPE
    101ATP1
    104ATP1
    105COM2

    Rob & Coronel Fig 6.3 (abridged): the EMPLOYEE–PILOT supertype/subtype relationship. Each pilot row matches exactly one employee row.

    Subtype discriminator

    Definition

    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:

    PROFESSORADMINISTRATORComment
    "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.

    TypeDisjoint constraintOverlapping constraint
    PartialSupertype 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.
    TotalEvery 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.

    Quick review

    Difference between a fan trap and a chasm trap?
    Fan trap: a path exists but is ambiguous (two 1:* fanning out from one entity). Chasm trap: a path is missing for some occurrences (because of optional participation). Fix fan traps by restructuring; fix chasm traps by adding the missing relationship.
    What does a subtype inherit from its supertype?
    Its attributes, its relationships, and its primary key.
    Disjoint + total: can the discriminator be null?
    No. Every supertype occurrence must be in exactly one subtype, so the discriminator must always have a value.
    Specialization vs generalization in one line each?
    Specialization: top-down, supertype → subtypes by unique characteristics. Generalization: bottom-up, subtypes → supertype by common characteristics.