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 BCNF 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) (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
Different PK Schedule (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
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
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
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.
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.
Not in BCNF Schedule (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
9 RoomAllocation (staffNo, Date, surgeryNo) PK: staffNo, Date AK: None FK: staffNo references Staff FDs: staffNo, Date ===> surgeryNo staffNo Date surgeryNo S Sep-04 S15 S Sep-04 S10 S Sep-04 S10 S Sep-04 S15 S Sep-04 S13 surgeryNo will be removed from the original table, But staffNo and Date remains in the original table.
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 P Sep-04 10:00 S1011 P Sep-04 12:00 S1024 P Sep-04 10:00 S1024 P Sep-04 14:00 S1032 P Sep-04 16:30 S1032 P Sep-04 18:00