Sub topic 15
Boyce-Codd Normal Form
Prerequisites and Working Rule
Assume you can read functional dependencies (FDs), compute attribute closure, identify candidate keys, and recognize third normal form (3NF).
A relation is in Boyce-Codd normal form (BCNF) when, for every nontrivial functional dependency:
\[ X \rightarrow Y \]
the determinant \(X\) is a superkey. A dependency is nontrivial when \(Y\) is not already contained in \(X\). A superkey is a set of attributes that determines every attribute in the relation.
BCNF is stricter than 3NF. It prevents every dependency whose left side is not a key, while 3NF allows one exception when the dependent attribute is prime, meaning it belongs to some candidate key.
A Relation in 3NF but Not BCNF
Consider:
R(A, B, C)
FDs: AB -> C, C -> BThe candidate keys are \(AB\) and \(AC\). Therefore, all three attributes are prime.
- For \(AB \rightarrow C\), \(AB\) is a key, so the dependency satisfies BCNF.
- For \(C \rightarrow B\), \(C^+ = \{B,C\}\), so \(C\) is not a superkey.
- Therefore, \(C \rightarrow B\) violates BCNF.
The relation is still in 3NF because \(B\) is prime. This example shows the difference:
| Normal form | Test for `C -> B` |
|---|---|
| 3NF | Allowed because `B` is prime |
| BCNF | Rejected because `C` is not a superkey |
Decomposing to BCNF
Decompose the violating dependency \(C \rightarrow B\) into:
- \(R_1(C,B)\)
- \(R_2(A,C)\)
The decomposition is lossless because the common attribute \(C\) determines all attributes of \(R_1\). However, it does not preserve the dependency \(AB \rightarrow C\). After decomposition, the dependencies available in the separate relations cannot derive that original dependency.
This is a central trade-off. BCNF removes more redundancy, but a BCNF decomposition can lose dependency preservation. A 3NF decomposition can be preferable when enforcing every important FD directly matters.
Common Errors and Decision Criteria
Do not test only candidate keys. A non-key determinant may still be a superkey if it contains a candidate key.
Do not conclude that a relation is in BCNF merely because it is in 3NF. The example above is a counterexample.
When choosing between 3NF and BCNF, use BCNF when eliminating redundancy is the priority and dependency checks can be handled elsewhere. Use 3NF when dependency preservation is important for enforcing rules within the decomposed schema.
Exercise
Is R(A, B, C) with FDs A -> B and B -> C in BCNF?
Show answer
No. A is not a superkey because A+ = {A, B, C}, actually making A a superkey; B is not a superkey because B+ = {B, C}. Therefore B -> C violates BCNF.