A Comprehensive Guide to Advanced ER Modeling
Extended Entity-Relationship diagrams enhance traditional ER diagrams with advanced modeling concepts to handle complex real-world scenarios.
In a university database, Person can be specialized into Student, Faculty, and Staff - each with their own specific attributes while sharing common person attributes.
Specialization is the process of defining a set of subclasses of an entity type (superclass).
PERSON
|
△ (triangle)
/ | \
STUDENT FACULTY STAFF
Superclass: EMPLOYEE (EmployeeID, Name, HireDate, Salary)
Specialized into:
Constraints: Disjoint (an employee can only be one type), Partial (not all employees need to be specialized)
Business Rules:
Generalization is the reverse process of specialization - defining a generalized superclass from existing entity types.
Before: CAR, TRUCK, MOTORCYCLE (separate entities)
After: VEHICLE (superclass) with CAR, TRUCK, MOTORCYCLE as subclasses
Common attributes: VehicleID, Make, Model, Year
Specific attributes: Car(NumDoors), Truck(CargoCapacity), Motorcycle(EngineType)
There are several strategies to convert EER diagrams into relational database tables:
PERSON (PersonID, Name, Address, Phone)
Specialized into:
Constraints: Disjoint, Total specialization
PERSON(PersonID, Name, Address, Phone)
STUDENT(PersonID*, StudentID, Major, GPA)
Foreign Key: PersonID references PERSON
FACULTY(PersonID*, EmployeeID, Department, Salary, Rank)
Foreign Key: PersonID references PERSON
STAFF(PersonID*, EmployeeID, Department, Salary, Position)
Foreign Key: PersonID references PERSON
STUDENT(PersonID, Name, Address, Phone, StudentID, Major, GPA)
FACULTY(PersonID, Name, Address, Phone, EmployeeID, Department, Salary, Rank)
STAFF(PersonID, Name, Address, Phone, EmployeeID, Department, Salary, Position)
PERSON(PersonID, Name, Address, Phone, PersonType,
StudentID, Major, GPA,
EmployeeID, Department, Salary, Rank, Position)
Constraints:
- PersonType ∈ {'Student', 'Faculty', 'Staff'}
- If PersonType = 'Student': StudentID, Major, GPA are NOT NULL
- If PersonType = 'Faculty': EmployeeID, Department, Salary, Rank are NOT NULL
- If PersonType = 'Staff': EmployeeID, Department, Salary, Position are NOT NULL
VEHICLE (VIN, Make, Model, Year, Color)
Specialized into:
Constraints: Overlapping, Partial specialization
Note: A vehicle can be both a CAR and HYBRID
VEHICLE(VIN, Make, Model, Year, Color)
CAR(VIN*, NumDoors, FuelType)
Foreign Key: VIN references VEHICLE
TRUCK(VIN*, CargoCapacity, NumAxles)
Foreign Key: VIN references VEHICLE
HYBRID(VIN*, BatteryCapacity, MPG)
Foreign Key: VIN references VEHICLE
-- A Toyota Prius would appear in both CAR and HYBRID tables
PERSON → EMPLOYEE → MEDICAL_STAFF
↓
DOCTOR, NURSE
PERSON → PATIENT
-- Level 1: Person
PERSON(PersonID, Name, DOB, Address, Phone)
-- Level 2: Person specialization
EMPLOYEE(PersonID*, EmployeeID, HireDate, Salary)
PATIENT(PersonID*, PatientID, InsuranceNumber)
-- Level 3: Employee specialization
MEDICAL_STAFF(PersonID*, LicenseNumber, Specialization)
-- Level 4: Medical Staff specialization
DOCTOR(PersonID*, MedicalDegree, YearsExperience)
NURSE(PersonID*, NursingDegree, Shift)
-- Administrative staff (direct from Employee)
ADMIN_STAFF(PersonID*, Department, AccessLevel)
Scenario: Library Management System
Tasks:
ITEM → {BOOK, MAGAZINE} (d, total)
BOOK → {TEXTBOOK, NOVEL} (d, total)
MAGAZINE(ItemID, Title, PublicationYear, IssueNumber, Frequency)
TEXTBOOK(ItemID, Title, PublicationYear, Author, ISBN, Pages, Subject, Edition)
NOVEL(ItemID, Title, PublicationYear, Author, ISBN, Pages, Genre, SeriesName)
Justification: Since all specializations are total, every item belongs to a leaf subclass. Strategy 2 eliminates the need for superclass tables while preserving all information.
Scenario: Online Store
Tasks:
Overlapping, Partial - Users can be both customer and seller, and some may be neither.
USER(UserID, Username, Email, RegistrationDate)
CUSTOMER(UserID*, ShippingAddress, PaymentInfo)
Foreign Key: UserID references USER
SELLER(UserID*, BusinessLicense, CommissionRate)
Foreign Key: UserID references USER
SELECT u.UserID, u.Username, u.Email
FROM USER u
INNER JOIN CUSTOMER c ON u.UserID = c.UserID
INNER JOIN SELLER s ON u.UserID = s.UserID;
| Scenario | Recommended Strategy | Reason |
|---|---|---|
| Disjoint, Total | Subclasses Only | No entity exists in superclass alone |
| Overlapping | Multiple Relations | Allows entities in multiple subclasses |
| Few specific attributes | Single Relation | Minimizes table count |
| Frequent superclass queries | Multiple Relations | Efficient superclass access |