Enhanced Entity-Relationship (EER) Model
Subclasses ยท Superclasses ยท Specialization ยท Generalization ยท Constraints ยท Mapping
ุฃุญูุงูุงู ุงูู entity type ุจูููู ููู ุชุฌู ูุนุงุช ุฃู ุฃููุงุน ูุฑุนูุฉ ููู ู ุนูู ุฅุถุงูู. ู ุซูุงู:
Superclass (ุงูููุน ุงูุฃุจ)
// EMPLOYEE entity has attributes:
Name, Ssn, Birth_date, Address
// Grouped into subclasses by JOB:
SECRETARY โ Typing_speed
TECHNICIAN โ Tgrade
ENGINEER โ Eng_type
// By MANAGEMENT role:
MANAGER โ manages PROJECT
// By PAY METHOD:
SALARIED_EMP โ Salary
HOURLY_EMP โ Pay_scaleโข ุงูู Subclass ุจุชู ุซู ููุณ ุงูู real-world entity ุจุณ ูู role ู ุฎุชูู
โข Entity ู ุด ู ู ูู ูููู ูู subclass ููุญุฏู โ ูุงุฒู ูููู ูู ุงูู superclass ุงูุฃูู
โข Member ูู ุงูู superclass ู ู ูู ูููู ูู ุฃูุชุฑ ู ู subclass ูู ููุณ ุงูููุช
ู ุซุงู: ู ูุธู ู ููุฏุณ ูุจูุงุฎุฏ ู ุฑุชุจ ุซุงุจุช โ ูู ENGINEER + SALARIED_EMPLOYEE ู ุนุงู
Superclass = Supertype = ุงูุฃุจ
Subclass = Subtype = ุงููุฑุน
ุงูุนูุงูุฉ = superclass/subclass relationship
ุฏู ุงูู EER diagram ุงูุฃุณุงุณู ุงููู ุจูุฌู ูู ุงูุงู ุชุญุงูุงุช. ุงููู ู ูููุณ!
ุงูู entity ูู ุง ุจูููู member ูู subclassุ ุจููุฑูุซ ูู ุญุงุฌุฉ ู ู ุงูู superclass:
// Inherited from EMPLOYEE (superclass):
Name โ inherited
Ssn โ inherited
Birth_date โ inherited
Address โ inherited
// Specific/Local attribute (own):
Typing_speed โ specific
// Inherited relationships:
WORKS_FOR Department โ inherited
WORKS_ON Project โ inherited1. ูู ุงูู attributes ู ู ุงูู superclass
2. ูู ุงูู relationships ู ู ุงูู superclass
3. ูุฅุฐุง ูุงูุช ูู hierarchy: ุจููุฑูุซ ู ู ูู predecessor superclasses
ุงูู attributes ุงูุฎุงุตุฉ ุจุงูู subclass ุจุชุชุณู ู "specific" ุฃู "local" attributes.
ู ุซุงู: TypingSpeed ุจุชุงุนุฉ SECRETARY
ูุงูู subclass ู ู ูู ูุดุงุฑู ูู specific relationships ุฒููุง.
ู ุซุงู: HOURLY_EMP BELONGS_TO TRADE_UNION
โฌ๏ธ Specialization
ุจูุจุฏุฃ ู ู ุงูู Superclass ููุนุฑูู ุงูู subclasses ู ููุง.
ุงุชุฌุงู Top-Down โ ู ู ููู ูุชุญุช
โฌ๏ธ Generalization
ุจูุจุฏุฃ ู ู entities ู ุชุดุงุจูุฉ ููุนู ู Superclass ู ุดุชุฑูุฉ.
ุงุชุฌุงู Bottom-Up โ ู ู ุชุญุช ูููู
Specialization = ู ู superclass ููู subclasses (Top-Down)
Generalization = ุฏู ุฌ entities ูู superclass ูุงุญุฏุฉ (Bottom-Up)
ุงูุณุคุงู "Specialization is the process of generating a superclass from different subclasses" โ ุงูุฌูุงุจ: FALSE! ุฏู Generalization!
ุงูู constraint ุฏู ุจุชุญุฏุฏ: ูู entity ู ู ูู ูููู ูู ุฃูุชุฑ ู ู subclass ูู ููุณ ุงูููุชุ
๐ต Disjoint (d) โ ูุง ุชุฏุงุฎู
ุงูู entity ูููู ูู ูุงุญุฏุฉ ุจุณ ู ู ุงูู subclasses.
๐ก Overlapping (o) โ ุชุฏุงุฎู ู ุณู ูุญ
ุงูู entity ู ู ูู ูููู ูู ุฃูุชุฑ ู ู subclass ูู ููุณ ุงูููุช.
ุงูู constraint ุฏู ุจุชุญุฏุฏ: ูู ูู entities ูู ุงูู superclass ูุงุฒู ุชููู ูู subclassุ
Single Line = Partial
ุจุนุถ ุงูู entities ูู ุงูู superclass ู ู ูู ู ุง ุชูููุด ูู ุฃู subclass.
// In EER diagram: SINGLE LINE
EMPLOYEE โโโ (d) โ Subclasses
// Meaning:
Some EMPLOYEES have no subtypeDouble Line = Total
ูู entity ูู ุงูู superclass ูุงุฒู ุชููู ูู ุนูู ุงูุฃูู subclass ูุงุญุฏุฉ.
// In EER diagram: DOUBLE LINE
EMPLOYEE โโ (d) โ Subclasses
// Meaning:
Every EMPLOYEE must be in โฅ1 subtypeTotal / Disjoint (T/D)
ูู entity ูู superclass ูู exactly ONE subclass. ุงูู ุฌู ูุน = Total ุจุงูุธุจุท.
Sum = Total
Total / Overlapping (T/O)
ูู entity ูู superclass ูู ุนูู ุงูุฃูู ONE subclassุ ูู ู ูู ุฃูุชุฑ. ุงูู ุฌู ูุน โฅ Total.
Sum โฅ Total
Partial / Disjoint (P/D)
ุจุนุถ entities ู ุด ูู ุฃู subclassุ ููู entity ูู subclass ูุงุญุฏุฉ max. ุงูู ุฌู ูุน < Total.
Sum < Total
Partial / Overlapping (P/O)
ุงูุญุงูุฉ ุงูุฃุนู โ ุจุนุถ entities ู ุด ูู subclassุ ูู ู ูู ุงูู ูุฌูุฏูู ูููููุง ูู ุฃูุชุฑ ู ู ูุงุญุฏุฉ.
Any case
๐ข Cardinality Formula โ ุงุชุญูุธูุง!
ุจููุชุฑุถ: Total Employees = 100, PartTime = 50, Consultant = 20
ุงูุณุคุงู: ุฅูู ููุน ุงูู participation ูู Permanent Employees = Xุ
X = 29 โ P/D
Sum = 99 < 100 โ Partial
99 โค 100 โ consistent with Disjoint
Partial / DisjointX = 81 โ Overlapping
Sum = 151 > 100 โ Overlapping
T ุฃู P? ู ุด ูุงุถุญ ู ู ุงูุฃุฑูุงู
Overlapping (T or P)X = 30 โ T/D
Sum = 100 = 100 โ Total
ูุง overlap โ Disjoint
Total / Disjoint โูู ุง Sum < Total โ ู ุด ู ู ูู Overlapping ูููู confirmed (ุจุณ ู ู ูู ูููู P/D)
ูู ุง Sum > Total โ Overlapping ู ุคูุฏ (P/O ุฃู T/O ุญุณุจ Coverage)
ูู ุง X = 30 ุจุงูุธุจุท โ T/D ุงููุญูุฏ ุงูู ู ูู
Total=100, PT=50, C=20, PE=40, intersection ุจูู ุงูู 3 subtypes = 10 ููุณ ุงูู records.
Sum = 110 > 100 โ Overlapping ู ุคูุฏ. ูุทุงูู ุง ุงูู intersection = 10 โ unique coverage = 110 - overlaps โฅ 100 โ ุงูุชุบุทูุฉ Total.
Answer: Total / Overlapping
ุนูุฏูุง specialization ูููุง superclass C ูm subclasses {S1, S2, ..., Sm}. ุฅุฒุงู ูุญูููุง ูู relational tablesุ
Multiple Relations โ Superclass + Subclasses
ุงูุฎูุงุฑ ุงูุขู ู ุงูุดุงู ู โ
EMPLOYEE(SSN, Name, Bdate, Addr)
SECRETARY(SSN, Typing_speed) โ FK
TECHNICIAN(SSN, Tgrade) โ FK
ENGINEER(SSN, Eng_type) โ FK(Total or Partial) + (Disjoint or Overlapping)
Multiple Relations โ Subclass Relations Only
ูู subclass ุจูุงุฎุฏ ูู attrs ุงูู superclass
SECRETARY(SSN, Name, Bdate, Typing_speed)
ENGINEER(SSN, Name, Bdate, Eng_type)
// NO separate EMPLOYEE tableTOTAL specialization ููุท!
ูู Partial โ employees ู ุด ูู ุฃู subclass ููุชุถูุนูุง
Single Relation with ONE Type Attribute
table ูุงุญุฏุฉ ุจู discriminating attribute
EMPLOYEE(SSN, Name, Bdate,
Typing_speed, Tgrade, Eng_type,
Profession) โ type attribute
// Example data:
1 | Ahmed | ... | NULL | Civil | Engineer
2 | Sara | ... | 100 | NULL | Secretaryูู Overlapping โ ูุงุญุฏ ุจูููู Secretary ูEngineer ู ุนุงู โ type attr ูุงุญุฏ ู ุด ููุงูุฉ โ violates uniqueness
ูุงุฒู ุชุนู ู: PK = (SSN + Profession)
Single Relation with MULTIPLE Type Attributes
Boolean flag ููู subclass
EMPLOYEE(SSN, Name, Bdate,
Typing_speed, Tgrade, Eng_type,
IsSecretary, โ YES/NO
IsTechnician, โ YES/NO
IsEngineer) โ YES/NO
// Example: engineer+secretary:
1 | Ahmed | 100 | Civil | YES | NO | YESDisjoint โ + Overlapping โ
ูู entity ุนูุฏู m flags (YES/NO)
๐ Quick Summary Table โ ุงุญูุธูุง!
| Option | # Tables | Total | Partial | Disjoint | Overlapping |
|---|---|---|---|---|---|
| 8A | m+1 | โ | โ | โ | โ |
| 8B | m | โ required | โ | recommended | valid, not recommended |
| 8C | 1 | โ | โ | โ required | โ |
| 8D | 1 | โ | โ | โ | โ |
"Option 8C works for Overlapping" โ FALSE! ููุท Disjoint
"Participation type doesn't affect the option" โ FALSE! 8B requires Total
"Option 8A works for any type" โ TRUE! โ
EER Quiz โ ุฃุณุฆูุฉ ุญููููุฉ ู ู Finals 2023/2024/2025
ุงุฎุชุจุฑ ููุณู ุนูู ูู ุงูู ูุงููู ุงููู ุงุชุดุฑุญุช
โข Specialization = Top-Down: ู ู superclass ูู subclasses
โข Generalization = Bottom-Up: ู ู entities ู ุชุดุงุจูุฉ ูุนู ู superclass
โข Option 8B ูุดุชุบู ููุท ู ุน Total participation
โข Option 8A ูุดุชุบู ู ุน ุฃู type
โข Options 8C ู8D ู ุด ู ูู ูููู ุงูู Total/Partial
โ Partial (ู ูุธู ูุงุญุฏ ู ุด ูู ุฃู subtype)
โ 99 โค 100 โ consistent with Disjoint (ู ููุด overlap ุถุฑูุฑู)
โ Partial / Disjoint โ
โ Overlapping ู ุคูุฏ (ุจุนุถ ุงูู ูุธููู ูู ุฃูุชุฑ ู ู subtype)
โ ูู Total ุฃู Partialุ ู ุด ูุงุถุญ ู ู ุงูุฃุฑูุงู ููุญุฏูุง โ "Overlapping (T or P)"
Dr. Ali: "Overlapping and Maybe Partial or Total"
Intersection = 10 (ููุณ 10 ู ูุธููู ูู ุงูู 3 types) โ unique employees covered โฅ 100 โ Total
โ Total / Overlapping โ
Option 8B โ m tables
Options 8C ู8D โ 1 table ููุท
Functional Dependencies & Normalization
Redundancy ยท FDs ยท 1NF ยท 2NF ยท 3NF
ูู ุง ุจูุญุท ู ุนููู ุงุช ู ุฎุชููุฉ ูู table ูุงุญุฏุฉ ุจุชุญุตู Redundancy = ุชูุฑุงุฑ ุงูุจูุงูุงุช. ูุฏู ุจูุณุจุจ 3 ู ุดุงูู:
โ Insertion Anomaly
ู ุด ู ู ูู ุชุถูู department ุฌุฏูุฏ ู ู ุบูุฑ employee โ ุงูู PK ููููู NULL ูุฏู ู ู ููุน!
โ ๏ธ Deletion Anomaly
ูู ุญุฐูุช ุขุฎุฑ ู ูุธู ูู departmentุ ุจุชุญุฐู ู ุนุงู ูู ู ุนููู ุงุช ุงูู department!
๐ Modification Anomaly
ูู ุบูุฑุช ุงุณู ุงูู departmentุ ูุงุฒู ุชุบูุฑู ูู ูู ุงูู rows โ ูุณูุงู ูุงุญุฏ โ inconsistency!
Ename | Ssn | Dnumber | Dname | Dmgr_ssn
Smith | 123456789 | 5 | Research | 333445555
Wong | 333445555 | 5 | Research | 333445555 โ repeated!
Narayan | 666884444 | 5 | Research | 333445555 โ repeated!
English | 453453453 | 5 | Research | 333445555 โ repeated!
// "Research" dept info repeated for EVERY employee in dept 5!ุชุนุฑูู: X โ Y ูุนูู: ูู tuple ุชุงููู ูููู ููุณ ููู ุฉ Xุ ูุงุฒู ูููู ุนูุฏูู ููุณ ููู ุฉ Y.
// SSN determines all employee info:
SSN โ Ename, Bdate, Address, Dnumber
// Department number determines dept info:
Dnumber โ Dname, Dmgr_ssn
// Composite key determines hours:
{SSN, Pnumber} โ Hoursโ Direct (Full) Dependency
ูู attribute ุจูุนุชู ุฏ ุนูู ุงูู PK ุจุงููุงู ู
StudentId โ Name, DOB, Address
โ ๏ธ Partial Dependency
attribute ุจูุนุชู ุฏ ุนูู ุฌุฒุก ู ู composite PK โ violates 2NF
SSN โ Ename (ูู table PK={SSN,Pno})
๐ Transitive Dependency
attribute ุจูุนุชู ุฏ ุนูู non-key attr โ violates 3NF
SSN โ Dno โ Dname
ุงููุงุนุฏุฉ: ูู ุฎููุฉ ูู ุงูู table ูุงุฒู ุชููู atomic = ููู ุฉ ูุงุญุฏุฉ ุจุณ.
โข Multi-valued attributes โ ู ูุธู ุนูุฏู ุฃูุชุฑ ู ู phone number ูู ุฎููุฉ ูุงุญุฏุฉ
โข Composite attributes โ ุงูู Name ู ุด atomic
โข Nested relations โ table ุฌูุง table
โข Repeated groups โ ุฃูุชุฑ ู ู ููู ุฉ ูู ููุณ ุงูุฎููุฉ
// DEPARTMENT table โ multi-valued Dlocations:
Dnumber | Dname | Dlocations
5 | Research | {Bellaire, Sugarland, Houston}
// โ NOT ATOMIC! Multiple values in one cell// DEPARTMENT:
Dnumber | Dname | Dmgr_ssn
// DEPT_LOCATIONS (separate table):
Dnumber | Dlocation
5 | Bellaire
5 | Sugarland
5 | Houston
// PK = {Dnumber, Dlocation}ุงูุดุฑุท: in 1NF + ูุง ููุฌุฏ Partial Dependency
Partial Dependency = attribute ุจูุนุชู ุฏ ุนูู ุฌุฒุก ู ู ุงูู composite PK ุจุณุ ู ุด ุงูู composite key ููู.
// EMP_PROJ(SSN, Pnumber, Hours, Ename, Pname, Ploc)
// PK = {SSN, Pnumber}
{SSN, Pnumber} โ Hours โ FULL โ
SSN โ Ename โ PARTIAL โ
Pnumber โ Pname, Ploc โ PARTIAL โ// EP1: Full dependency only
EP1(SSN, Pnumber, Hours)
// {SSN, Pnumber} โ Hours โ
// EP2: SSN partial dep
EP2(SSN, Ename)
// SSN โ Ename โ
// EP3: Pnumber partial dep
EP3(Pnumber, Pname, Plocation)
// Pnumber โ Pname, Ploc โุงูุดุฑุท: in 2NF + ูุง ููุฌุฏ Transitive Dependency
Transitive Dependency = A โ B โ C ุญูุซ B ูู non-key attribute.
ุจู ุนูู ุชุงูู: ู ููุด non-key attribute ูุญุฏุฏ non-key attribute ุชุงูู
// EMP_DEPT(Ename, SSN, Bdate, Addr, Dno, Dname, Dmgr)
// PK = SSN
SSN โ Ename, Bdate, Addr, Dno โ direct โ
Dno โ Dname, Dmgr_ssn โ Dno is non-key!
// So transitively:
SSN โ Dno โ Dname, Dmgr โ TRANSITIVE โ// ED1: Employee info (keep Dno as FK)
ED1(SSN, Ename, Bdate, Address, Dno)
// SSN โ Ename, Bdate, Addr, Dno โ
// ED2: Department info (separate!)
ED2(Dno, Dname, Dmgr_ssn)
// Dno โ Dname, Dmgr โ1. ุญุฏุฏ ุงูู transitive deps
2. ูู transitive dep โ relation ุฌุฏูุฏุฉ
3. ุงูู determinant (Dno) ูุจูู FK ูู ุงูู original table ูPK ูู ุงูุฌุฏูุฏุฉ
ููุงุฎุฏ ุงูู Reservation relation ุฏู ููุทุจู ุนูููุง 2NF ูุจุนุฏูู 3NF:
Reservation(PerformerId, AgentId, VenueId, EventId,
PerformerName, PerformerLoc, PerformerType, Fee,
AgentName, AgentLoc, EventType, EventName,
VenueName, VenueLoc, BookingDate)
// FDs:
{PerformerId,AgentId,VenueId,EventId} โ BookingDate
EventId โ EventType, EventName
VenueId โ VenueName, VenueLocation
AgentId โ AgentName, AgentLocation
PerformerId โ PerformerName, PerformerLoc, PerformerType
PerformerType โ FeeStep 1: 2NF โ Remove Partial Deps
Performer(PerformerId, PName, PLoc, PType, Fee)
Event(EventId, EventType, EventName)
Agent(AgentId, AgentName, AgentLoc)
Venue(VenueId, VenueName, VenueLoc)
Reservation(PerformerId, AgentId, VenueId,
EventId, BookingDate)Step 2: 3NF โ Remove Transitive Deps
Performer(PerformerId, PName, PLoc, PType)
PerformerType(PerformerType, Fee) โ new!
Event(EventId, EventType, EventName)
Agent(AgentId, AgentName, AgentLoc)
Venue(VenueId, VenueName, VenueLoc)
Reservation(PerformerId, AgentId, VenueId,
EventId, BookingDate)๐ ููู ุชุญุฏุฏ ุงูู Normal Formุ
| Normal Form | ุงูุดุฑุท ุงููู ูุงุฒู ููุทุจู | ุงูู Violation ุงููู ุจุชูุณุฑูุง |
|---|---|---|
| 1NF | ููู atomic + PK ู ุญุฏุฏุฉ | Multi-valued / composite attrs |
| 2NF | in 1NF + no partial deps | Non-key attr depends on PART of composite PK |
| 3NF | in 2NF + no transitive deps | Non-key attr determines another non-key attr |
Normalization Quiz โ ุฃุณุฆูุฉ ุญููููุฉ ู ู Finals 2023/2024/2025
ุงุฎุชุจุฑ ููู ู ููู FDs ูุงูู Normal Forms
ูู ุง A ูุธูุฑ โ ู ุด ููุณ ููู ุฉ C = A ูุง ูุญุฏุฏ C โ A โ C โ
Dr. Ali: c. A โ B
โข StudentId โ StuName = Partial dep โ Student(StudentId, StuName)
โข CourseId โ CourseName = Partial dep โ Course(CourseId, CourseName)
โข {StudentId, CourseId} โ Grade = Full dep โ Enroll(StudentId, CourseId, Grade)
Dr. Ali: a
Fix: ูุตูู INSTR โ I_OFFICE ูู relation ุฌุฏูุฏุฉ (INSTR, I_OFFICE)
ุงูู original table ุจููุถู ูุญุชูุธ ุจู ROOM ู INSTR (INSTR ุจูู FK)
Dr. Ali: a
ููู: StudentID โ StudentName (Partial dep โ violates 2NF)
CourseID โ CourseName (Partial dep โ violates 2NF)
โ in 1NF but violates 2NF and 3NF
Dr. Ali: c
E3 ุนูุฏูุง multi-valued attributes โ violates 1NF โ below 1NF โ Denormalized!
ู ุด ู ูู ุฅู E1 in 2NF ูE2 in 3NF โ ุงูุฃุถุนู ูู ุงููู ุจูุญุฏุฏ.
Dr. Ali: a. Denormalized
ููู ู ุด ุถุงู ู 2NF ุฃู 3NF (ู ู ูู ูููู ููู partial ุฃู transitive deps).
Dr. Ali: a. 1st NF
Transitive = ูุฎุงูู 3NF.
Full/Direct dependency = ู ุทููุจุฉ ูู 2NF ู3NF.
ููู: UnitPrice โ ูู ุณุนุฑ ุงูู ูุชุฌุ ุจูุนุชู ุฏ ุนูู ProductID ููุท (ู ุด ุงูู composite PK ูุงู ู) โ Partial Dependency โ violates 2NF
ูู ุงู TotalPrice ู ุดุชูุฉ (derived) ู ู Quantity ร UnitPrice.
Dr. Ali: a. 1st NF
Option A ูุตู 2NF ููุนุงู ู ุง.
Option B ูุตู 2NF (removing partial deps).
Option C ูู ุงูุชุนุฑูู ุงูุตุญูุญ ููู 3NF.
Cheat Sheet โ ู ูุฎุต ููู ุฑุงุฌุนุฉ ุงูุณุฑูุนุฉ
ุงุญูุธ ุงูุฌุฏูู ุฏู ุงุฏุฎู ุงูุงู ุชุญุงู ุจุซูุฉ!