Example of converting 3NF table to BCNF
student
subject
teacher
Alice
Alice
Bob
Bob
Math
Physics
Math
Physics
Prof. White
Prof. Green
Prof. White
Prof. Black
Business rules:
- Each student has one teacher
per subject
- Each teacher teaches only one
subject
- each subject can have multiple
teachers
(example from Database Management
Systems, Rajiv Chopra)
student
subject
teacher
There are two candidate keys in this table:
(student, subject) and (student, teacher).
However, in the second case, subject is dependent on PART of the candidate
key only (teacher)
Solution:
split table into (student, teacher) and (teacher, subject) OR
split table into (student, subject, teacher_id), (teacher_id, teacher, subject)
student
teacher
teacher
subject
Alice
Alice
Bob
Bob
Prof. White
Prof. Green
Prof. White
Prof. Black
Prof. White
Prof. Green
Prof. Black
Math
Physics
Physics