What is BCNF, and how is it different from 3NF?
HardConceptNormalization
Answer
A table is in Boyce-Codd normal form (BCNF) if, for every non-trivial functional dependency X -> Y, X is a super key. 3NF is slightly weaker: it also allows X -> Y when every attribute in Y is prime, meaning part of some candidate key.
- Every BCNF table is in 3NF, but not every 3NF table is in BCNF.
- The difference appears only when a table has overlapping composite candidate keys.
- A BCNF decomposition is always lossless but may not preserve every dependency, whereas 3NF can always preserve them.
Example: teaches(student, subject, teacher), where each teacher teaches one subject (teacher -> subject) and each student has one teacher per subject ({student, subject} -> teacher):
student | subject | teacher
Asha | DBMS | Rao
Ravi | DBMS | Mehta
Asha | OS | Iyer
The candidate keys are {student, subject} and {student, teacher}. The table is in 3NF, because subject is prime, but not in BCNF, because teacher is not a super key. Decompose it into (teacher, subject) and (student, teacher).