Advanced Database Systems: Lecture # 8 3Nf + Advanced Nfs (Revision)
Advanced Database Systems: Lecture # 8 3Nf + Advanced Nfs (Revision)
A→B→C
C is transitively dependent on A
Instructor: Furqan Shahid
Normalization example-3
STUDENT
RegNo Name Address DateOfBirth DegreeTitle DegreeDuration DegreeFee
1001 Usman H#1,St#1, City1 17-May-1990 BS CS 8-semester 250,000
1002 Uzair H#2,St#2,City1 09-Aug-1991 MS CS 4-semester 175,000
1003 Bilal H#1,St#1,City2 19-Apr-1989 BS CS 8-semester 250, 000
• Anomalies:
• Can’t insert record of “Degree” without “Student”
3NF
STUDENT:
RegNo Name Address DateOfBirth DegreeTitle DEGREE:
MANAGER:
MgrNO Name Experience DateOfHiring AllocatedCarNo • Still contains transitive
1001 Usman 5 years 17-May-2016 IDG 6877 dependencies
1002 Uzair 7 years 09-Aug-2017 RI 567
InsurerCode → Office, Contact
1003 Bilal 4 years 19-Apr-2014 LHR 3003
CAR:
CarRegNo CarModel CarPrice CarInsurer InsurerOffice InsurerContact
IDG 6877 2015 650,000 SLP Islamabad 051-xxxxxx
RI 567 2017 775,000 JIP Lahore 042-xxxxxx
LHR 3003 2014 550, 000 SLP Islamabad 051-xxxxxx Instructor: Furqan Shahid
Solution example-4 (cont.)
MANAGER:
MgrNO Name Experience DateOfHiring AllocatedCarNo
1001 Usman 5 years 17-May-2016 IDG 6877
1002 Uzair 7 years 09-Aug-2017 RI 567
1003 Bilal 4 years 19-Apr-2014 LHR 3003
CAR:
CarRegNo Model Price InsurerCode
IDG 6877 2015 650,000 SLP
RI 567 2017 775,000 JIP
LHR 3003 2014 550, 000 SLP
INSURER:
InsurerCode Office Contact
SLP Islamabad 051-xxxxxx
JIP Lahore 042-xxxxxx
PROJECT:
Code Duration Cost Sponsor SpsOffice SpsPhone
PRJ-1 6 month 7 billion AA Ent. Karachi 021-xxxxxx
PRJ-2 8 month 12 billion AM Co. Lahore 042-xxxxxx
PRJ-3 1.5 month 3 billion AB Co. Islamabad 051-xxxxxx
PROJECT:
Code Duration Cost Sponsor SpsOffice SpsPhone • Contains transitive dependencies
PRJ-1 6 month 7 billion AA Ent. Karachi 021-xxxxxx (not in 3NF)
PRJ-2 8 month 12 billion AM Co. Lahore 042-xxxxxx SponsorCode → Office, Phone
PRJ-3 1.5 month 3 billion AB Co. Islamabad 051-xxxxxx
PROJECT: SPONSOR:
Code Duration Cost SponsorCode Code Office Phone
PRJ-1 6 month 7 billion AA Ent. AA Ent. Karachi 021-xxxxxx
PRJ-2 8 month 12 billion AM Co. AM Co. Lahore 042-xxxxxx
PRJ-3 1.5 month 3 billion AB Co. AB Co. Islamabad 051-xxxxxx
• Foreign key constraint: Each non-null value in the foreign key must
already be existing in the corresponding parent key
• Also known as referential integrity