The Boyce-Codd Normal Form (BCNF) is a normalization form in relational database theory that aims to eliminate redundancy and anomalies in a database. It is a stricter form of the Third Normal Form (3NF) and is often considered an extension of it.
A relation (table) is in Boyce-Codd Normal Form if it meets the following conditions:
-
The relation is in Third Normal Form (3NF): This means it is already in First and Second Normal Form, and there are no transitive dependencies between the attributes.
-
Every non-trivial functional dependency X→YX→Y has a superkey as the determinant: This means that for every functional dependency where XX is the set of attributes determining YY, XX must be a superkey. A superkey is a set of attributes that can uniquely identify the entire relation.
Differences from Third Normal Form (3NF)
While Third Normal Form requires that any attribute not part of the primary key must be directly dependent on it (not transitively through another attribute), BCNF goes a step further. It requires that all determinants (the left-hand side of functional dependencies) must be superkeys.
Example
Consider a relation R
with attributes A
, B
, and C
, and the following functional dependencies:
To check if this relation is in BCNF, we proceed as follows:
- We observe that A→BA→B is not problematic if AA is a superkey.
- However, B→CB→C is problematic if BB is not a superkey, as BB in this case cannot uniquely identify the entire relation.
If BB is not a superkey, the relation is not in BCNF and must be decomposed into two relations to meet BCNF requirements:
- One relation containing BB and CC
- Another relation containing AA and BB
Summary
The Boyce-Codd Normal Form is stricter than the Third Normal Form and ensures that there are no functional dependencies where the left-hand side is not a superkey. This helps to avoid redundancy and anomalies in the database structure and ensures data integrity.