Boyce-Codd Normal Form (BCNF)

Boyce-Codd Normal Form (BCNF) is a stricter version of the Third Normal Form (3NF). It addresses certain anomalies that can still occur even in 3NF, particularly when there are multiple overlapping candidate keys. A relation is in BCNF if, for every non-trivial functional dependency X → Y, X is a superkey.

Definition of BCNF

A relation schema R is in BCNF if and only if for every functional dependency X → Y in R, at least one of the following is true:

In simpler terms, for any dependency, the determinant (the left side of the arrow, X) must be a candidate key (or part of one).

Key Differences from 3NF

3NF requires that for every non-trivial functional dependency X → Y, either X is a superkey or Y is a prime attribute. BCNF removes the second condition, requiring X to always be a superkey for non-trivial dependencies.

BCNF Dependency: If a relation R is not in BCNF, it must contain a functional dependency X → Y such that X is not a superkey and X → Y is non-trivial.

When BCNF is Necessary

BCNF is particularly important when:

Example

Scenario: Student Course Enrollments

Consider a relation Enrollment with attributes:

  • StudentID
  • CourseID
  • InstructorID
  • InstructorRoom

Assume the following functional dependencies:

  1. {StudentID, CourseID}{InstructorID} (A student enrolls in a specific course, which determines the instructor for that enrollment.)
  2. {InstructorID}{InstructorRoom} (Each instructor is assigned a specific room.)

Candidate keys:

  • {StudentID, CourseID}

Let's analyze the dependencies:

Dependency 1: {StudentID, CourseID}{InstructorID}

  • The determinant {StudentID, CourseID} is a candidate key. This dependency is fine for BCNF.

Dependency 2: {InstructorID}{InstructorRoom}

  • The determinant {InstructorID} is not a superkey for the Enrollment relation.
  • This violates BCNF.

The relation Enrollment is not in BCNF due to dependency 2.

Decomposition to BCNF

To decompose a relation into BCNF, we break down the relation based on the violating functional dependency. For the dependency X → Y where X is not a superkey:

  1. Create a new relation consisting of the attributes in X and Y.
  2. Remove the attributes in Y from the original relation.

Applying this to our example:

The violating dependency is {InstructorID}{InstructorRoom}.

  1. Create a new relation, say InstructorInfo, with attributes {InstructorID, InstructorRoom}. This relation is now in BCNF.
  2. Remove InstructorRoom from the original Enrollment relation, leaving {StudentID, CourseID, InstructorID}.

The decomposed relations are:

Both decomposed relations are now in BCNF.

Benefits of BCNF

Drawbacks of BCNF

BCNF is generally the highest level of normalization considered for practical relational database design, providing a strong guarantee against functional dependency anomalies.