Published on

Database Normalization: BCNF

BCNF (Boyce-Codd Normal Form) is a type of database normalization that is stricter than 3NF (Third Normal Form). It's used to eliminate redundancy and potential anomalies in relational database design.


πŸ” TL;DR

A relation is in BCNF if every determinant is a candidate key.


πŸ“˜ Quick Breakdown

  • A determinant is any attribute (or set of attributes) on the left-hand side of a functional dependency (e.g., A β†’ B, A is the determinant).
  • A candidate key is a minimal set of attributes that can uniquely identify every tuple (row) in the relation.

πŸ“‹ Formal Definition

A relation R is in Boyce-Codd Normal Form (BCNF) if:

For every non-trivial functional dependency X β†’ Y in R, X is a super key (i.e., it can uniquely identify tuples).

"Non-trivial" means Y is not a subset of X.


βœ… When Is BCNF Needed?

Even if a table is in 3NF, it might still not be in BCNF if:

  • There are multiple candidate keys, and
  • Some non-primary candidate key determines attributes

πŸ”§ Example

Let’s say you have a table:

StudentIDCourseInstructor
1MathProf. A
2MathProf. A
3HistoryProf. B

Functional dependencies:

  • StudentID β†’ Course, Instructor βœ… (StudentID is a candidate key)
  • Course β†’ Instructor ❌ (Course is not a candidate key)

Here, Course β†’ Instructor violates BCNF because Course is not a superkey.


πŸ’‘ Fixing It

Split into two tables:

  1. StudentCourse(StudentID, Course)
  2. CourseInstructor(Course, Instructor)

Now both are in BCNF, and the redundancy is removed.


Here are the BCNF-fixed tables derived from the example:

1) StudentCourse

Stores which course each student takes. PK: (StudentID, Course)

StudentIDCourse
1Math
2Math
3History

2) CourseInstructor

Captures the functional dependency Course β†’ Instructor. PK: Course

CourseInstructor
MathProf. A
HistoryProf. B