Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a...

10
Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1

Transcript of Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a...

Page 1: Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.

Boyce-Codd Normal Form (BCNF)

Definition

R in 1NF and

Every determinant (the left side of a FD) is a candidate key.

1

Page 2: Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.

Not in BCNFSchedule (staffNo, dentistName, patNo, patName, surgeryNo, date, time)

PK: surgeryNo, Date, Time

FDs:

surgeryNo, Date, Time ===> staffNo, patNo (All)

staffNo, Date, Time ===> surgeryNo, patNo (All)

patNo, Date, Time ===> staffNo, surgeryNo (All)

(The determinants are candidate keys)

staffNo ===> dentistName (transitive on PK)

patNo ===> patName (transitive on PK)

staffNo, Date ===> surgeryNo (surgeryNo is a PK attribute!)

(The determinants are NOT candidate keys)

2

Page 3: Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.

Different PKSchedule (staffNo, dentistName, patNo, patName, surgeryNo, date, time)

PK: staffNo, date, time

AK: surgeryNo, date, time

patNo, date, time

FK: None

staffNo, Date, Time ===> patNo, surgeryNo (All)

surgeryNo, Date, Time ===> staffNo, patNo (All)

patNo, Date, Time ===> staffNo, surgeryNo (All)

staffNo ===> dentistName (partial on PK)

patNo ===> patName (transitive on PK)

staffNo, Date ===> surgeryNo (partial on PK!)3

Page 4: Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.

Schedule (staffNo, dentistName, patNo, patName, surgeryNo, date, time)

PK: surgeryNo, Date, Time

FDs:

surgeryNo, Date, Time ===> staffNo, patNo (All)

staffNo, Date, Time ===> surgeryNo, patNo (All)

patNo, Date, Time ===> staffNo, surgeryNo (All)

staffNo ===> dentistName (determinant is NOT candidate key)

patNo ===> patName (determinant is NOT candidate key)

staffNo, Date ===> surgeryNo (determinant is NOT candidate key)

New Tables in BCNF

Staff (staffNo, dentistName)

Patient (patNo, patName)

RoomAllocation (staffNo, Date, surgeryNo)

Schedule (staffNo, patNo, date, time)

PK & FK!4

Page 5: Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.

Schedule (staffNo, patNo, date, time)

PK: staffNo, date, time

AK: patNo, date, time

FK: staffNo references Staff

patNo references Patient

staffNo, Date references Room

FDs:

staffNo, Date, Time ===> patNo

patNo, Date, Time ===> staffNo

PK and AK can be switched.

5

Patient (patNo, patName)

PK: patNo

AK: None

FK: None

FDs:

patNo ===> patName

Staff (staffNo, dentistName)

PK: staffNo

AK: None

FK: None

FDs:

staffNo ===> dentistName

RoomAllocation (staffNo, Date, surgeryNo) PK: staffNo, Date AK: None FK: staffNo references Staff staffNo, Date ===> surgeryNo

Page 6: Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.

6

Staff (staffNo, dentistName)

PK: staffNo

AK: None

FK: None

FDs:

staffNo ===> dentistName

staffNo dentistName

------------- --------------------

S1011 Tony Smith

S1024 Helen Pearson

S1032 Robin Plevin

dentistName will be removed from the original table,

But staffNo remains in the original table.

Page 7: Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.

7

Patient (patNo, patName)

PK: patNo

AK: None

FK: None

FDs:

patNo ===> patName

patNo patName

------------ -------------------

P100 Gillian White

P105 Jill Bell

P108 Ian MacKay

P110 John Walker

patName will be removed from the original table,

But patNo remains in the original table.

Page 8: Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.

Not in BCNFSchedule (staffNo, dentistName, patNo, patName, surgeryNo, date, time)

Schedule (staffNo, patNo, surgeryNo, date, time)

FDs:

surgeryNo, Date, Time ===> staffNo, patNo (All)

staffNo, Date, Time ===> surgeryNo, patNo (All)

patNo, Date, Time ===> staffNo, surgeryNo (All)

staffNo, Date ===> surgeryNo

(The determinants are NOT candidate keys)

8

Page 9: Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.

9

RoomAllocation (staffNo, Date, surgeryNo)

PK: staffNo, Date

AK: None

FK: staffNo references Staff

FDs:

staffNo, Date ===> surgeryNo

staffNo Date surgeryNo

---------- ------------ --------------

S1011 12-Sep-04 S15

S1024 12-Sep-04 S10

S1024 14-Sep-04 S10

S1032 14-Sep-04 S15

S1032 15-Sep-04 S13

surgeryNo will be removed from the original table,

But staffNo and Date remains in the original table.

Page 10: Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.

10

Schedule (staffNo, patNo, date, time)

PK: patNo, date, time

AK: staffNo, date, time

FK: staffNo references Staff

patNo references Patient

staffNo, Date references RoomAllocation

FDs:

staffNo, Date, Time ===> patNo

patNo, Date, Time ===> staffNo

staffNo patNo date time

---------- ---------- ------------- ----------

S1011 P100 12-Sep-04 10:00

S1011 P105 12-Sep-04 12:00

S1024 P108 12-Sep-04 10:00

S1024 P108 14-Sep-04 14:00

S1032 P105 14-Sep-04 16:30

S1032 P110 15-Sep-04 18:00