Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 3630 Database Design and Implementation

Similar presentations


Presentation on theme: "CS 3630 Database Design and Implementation"— Presentation transcript:

1 CS 3630 Database Design and Implementation

2 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 PK.

3 Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName)
Primary Key: PNo, Start FDs: PNo, Start  All PNo  PAddress, ONo, Oname (Partial on PK!) Lease1 (PNo, PAddress, ONo, OName) Primary Key: Pno Alternate Key: None Foreign Key: None PNo  All PAddress  All ONo  OName Lease (RNo, RName, PNo, Start, Finish, Rent) Foreign Key: PNo References Lease1 RNo  RName

4 Better Name for the New Table
Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName) Primary Key: PNo, Start Better Name for the New Table Lease1 (PNo, PAddress, ONo, OName) Primary Key: Pno Property Lease (RNo, RName, PNo, Start, Finish, Rent)

5 Property (PNo, PAddress, ONo, OName)
Primary Key: PNo FDs: PNo  All PAddress  All ONo  OName Table Instance PNo PAddress ONo OName P main O Tina P main O Tony P first O Tony P first O Tony In 2NF? But still some Redundancy Reason?

6 Third Normal Form (3NF) No Transitive FDs on PK.
Relation R in 2NF, and No non-Primary-Key attribute is transitively functionally dependent on the primary key Then R is in 3NF. No Transitive FDs on PK.

7 Transitive FDs If A  B and B  C Then A  C is always TRUE
(provided A is not functionally dependent on either B or C) (NO cycle!)

8 Transitive FDs A B C If A  B and B  C Then A  C

9 Transitive FDs A B C If A  B and B  C Then A C
Provided not B  A (A and B are equivalent) nor C  A (A, B and C are equivalent) No Cycle!

10 Property (PNo, PAddress, ONo, OName) FDs: PNo  All PAddress  All
Primary Key: PNo FDs: PNo  All PAddress  All ONo  OName Table Instance PNo PAddress ONo OName P main O Tina P main O Tony P first O Tony P first O Tony In 2NF, but still some redundancy Not in 3NF! Ono  Oname (Oname is transitively functionally dependent on Pno)

11 Decompose Property into 3NF
Property (PNo, PAddress, ONo, OName) PNo  All PAddress  All ONo  OName Property1 (ONo, OName) Primary Key: Ono Alternate Keys: None Foreign Keys: ? FDs: ONo  Oname Property (PNo, PAddress, ONo) Primary Key: PNo Alternate Keys: PAddress Foreign Keys: ? FDs: PNo  All PAddress  All

12 Decompose Property into 3NF
Property (PNo, PAddress, ONo, OName) PNo  All PAddress  All ONo  OName Property1 (ONo, OName) Primary Key: Ono Alternate Keys: None Foreign Keys: None FDs: ONo  Oname Better table name? Owner Property (PNo, PAddress, ONo) Primary Key: PNo Alternate Keys: PAddress Foreign Keys: Ono references Property1 FDs: PNo  All PAddress  All

13 Decompose Property into 3NF
Property (PNo, PAddress, ONo, OName) PNo  All PAddress  All ONo  OName Owner (ONo, OName) Primary Key: Ono Alternate Keys: None Foreign Keys: None FDs: ONo  Oname Property (PNo, PAddress, ONo) Primary Key: PNo Alternate Keys: PAddress Foreign Keys: Ono references Owner FDs: PNo  All PAddress  All

14 Table Instances Property PNo PAddress ONo OName
P main O Tina P main O Tony P first O Tony P first O Tony Property PNo PAddress Ono P main O100 P main O109 P first O109 P first O109 Owner ONo OName O Tina O Tony

15 Final Tables Lease Property Owner

16 Relation R R (A, B, C, D, E, F) Primary Key: A, B Alternate Keys: None Functional Dependencies: A, B  All C  D E  F Is it in 2NF? Is it in 3NF? How many tables we will have to decompose it into 3NF?

17 R (A, B, C, D, E, F) PK: A, B AK: None FK: None FDs: A, B  All C  D
Table Instance A B C D E F x se y cis x cis y ct Decompose into 3NF Each table: DBDL FDs Table instance

18 Assignment 5-2 Due Monday, March 5 Quiz 2 Wednesday, March 7 Lab 206
Schedule Assignment 5-2 Due Monday, March 5 Quiz 2 Wednesday, March 7 Lab 206


Download ppt "CS 3630 Database Design and Implementation"

Similar presentations


Ads by Google