Download presentation
Presentation is loading. Please wait.
1
CS 3630 Database Design and Implementation
2
Unnormalized Form (UNF)
student courses Joe Clifton CS3630 CS3340 CS3230 Multi-Value attribute Common in reports 2NF and 3NF could be in one note.
3
First Normal Form (1NF) No multi-value attributes
Done when mapping E-R model to relational schema DBDL
4
Second Normal Form (2NF)
A relation R is in 1NF, and every non-primary-key attribute is fully functionally dependent on the primary key Then R is in 2NF No Partial FDs on the PK.
5
Partial FDs X, Y W is a partial FD if X W or Y W is true
Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName) PAddress, Start All PAddress, Start PNo, ONo, OName PAddress PNo, ONo, OName
6
Second Normal Form (2NF)
No Partial FDs on the PK. PK All other attributes Assume a table with a simple PK of Att1 Att1 All other attributes Is it in 2NF? Cannot have partial FD on simple PK Assume a table with a composite PK of Att1 and Att2 Att1, Att2 Att3, Att4, Att5 (All other attributes) It’s possible Att2 Att5 Att1, Att2 Att3, Att4
7
Example Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName) PK: PNo, Start AK: PNo, Finish PAddress, Start PAddress, Finish FDs: PNo, Start All PNo, Finish All PAddress, Start All PAddress, Finish All RNo RName ONo Oname PAddress PNo, ONo, OName PNo PAddress, ONo, OName Partial FD on Primary Key?
8
Table Instance Not in 2NF! Poor Performance Redundancy Inconsistency
RNo RName PNo PAddress Start Finish Rent Ono OName R John P main O Tina R Mike P main O Tina R Kay P main O Tina R John P main O Tony R Scot P first O Tony PNo, Start All other attributes (Partial on Primary Key) PNo PAddress, ONo, OName Not in 2NF! Poor Performance Redundancy Inconsistency What to Do? Move the attributes to another table!
9
Decompose Lease into 2NF
Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName) PK: PNo, Start Partial FD on Primary Key PNo PAddress, ONo, OName Remove partial dependent on Primary Key Create a new relation Which attributes are in the new relation? All attributes in the partial FD (both side of) Lease1 (PNo, PAddress, ONo, OName) Which attributes are left in the original relation? PK remains the same Lease (RNo, RName, PNo, Start, Finish, Rent) PK? FK?
10
Lease1 (PNo, PAddress, ONo, OName)
PK: PNo AK: PAddress FK: None (from this conversion) Functional Dependencies: PNo All other attributes PAddress PNo, ONo, OName ONo OName In 2NF? Lease (RNo, RName, PNo, Start, Finish, Rent) PK: PNo, Start AK: PNo, Finish FK: PNo references Lease1 Functional Dependencies: PNo, Start All other attributes PNo, Finish All other attributes RNo Rname In 2NF?
11
Relation/Table Instances
Lease Rno RName PNo PAddress Start Finish Rent Ono OName R101 John P main O100 Tina R102 Mike P main O100 Tina R103 Kay P main O100 Tina R101 John P main O110 Tony R105 Scot P first O109 Tony Lease1 PNo PAddress ONo OName P main O Tina P main O Tony P first O Tony PNo, PAddress, Ono, OName (Lease)
12
Removing Duplicates Lease1 PNo PAddress ONo OName
P main O Tina P main O Tony P first O Tony P main O Tina P main O Tony P first O Tony
13
Lease (before) Lease (after) RNo RName PNo Start Finish Rent
RNo RName PNo PAddress Start Finish Rent Ono OName R John P main O Tina R Mike P main O Tina R Kay P main O Tina R John P main O Tony R Scot P first O Tony Lease (after) RNo RName PNo Start Finish Rent R John P R Mike P R Kay P R John P R Scot P RNo, RName, RNo, Start, Finish, Rent (Lease)
14
Some FDs are lost Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName) PAddress, Start All PAddress, Finish All Lease1 (PNo, PAddress, ONo, OName) Lease (RNo, RName, PNo, Start, Finish, Rent)
15
Assignment 5-1
16
Assumptions Identify all non-trivial FDs NIN eName contractNo hNo, hLoc hNo hLoc NIN, contractNo All ( NIN, contractNo hours) Choose a PK: NIN, contractNo List all AKs: NONE
17
Schedule Assignment 61 Due Thursday, March 1, by 5 pm Quiz 2 Wednesday, March 7 Covers A4 and A51, A61
18
Assignment 4
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.