← Back to SQL, page 11

sql-0201 · Hard senior

How does Boyce-Codd normal form differ from 3NF? Give a case that is in 3NF but not BCNF.

BCNF requires that for every non-trivial functional dependency X → Y, X is a superkey. 3NF allows an exception when Y is part of a candidate key. A classic case: tutoring(student, subject, tutor), where each tutor teaches one subject (tutor → subject) and a student has one tutor per subject. It is in 3NF but not BCNF, because tutor is not a superkey.

Full answer

In tutoring(student, subject, tutor):

  • (student, subject) → tutor: each student has one tutor per subject.
  • tutor → subject: each tutor teaches only one subject.

Candidate keys are (student, subject) and (student, tutor). The dependency tutor → subject has a left side that is not a superkey, so BCNF fails. 3NF accepts it because subject is part of a candidate key.

The practical problem: a tutor's subject is repeated for each student, and if the tutor switches subject, many rows must change.

The BCNF decomposition is tutors(tutor, subject) and tutoring(student, tutor). The catch is that the rule "one tutor per student per subject" can no longer be enforced with a simple key, because subject and student are now in different tables. This loss of dependency preservation is why some designs stop at 3NF.

Key points

  • BCNF: every determinant is a superkey
  • 3NF allows dependencies into key attributes
  • Overlapping candidate keys create 3NF-but-not-BCNF cases
  • BCNF decomposition may not preserve all dependencies

Common mistakes

  • Saying 3NF and BCNF are the same
  • Ignoring the dependency-preservation trade-off

Follow-ups

  • How would you enforce the lost rule after decomposition?
  • What are 4NF and multivalued dependencies?

Tips

  • Name the determinant that breaks BCNF