A table is in Boyce-Codd normal form (BCNF) if and only if it is in 3NF and every determinant is a candidate key.
- Anomalies can occur in relations in 3NF if there is a composite key in which part of that key has a determinant which is not itself a candidate key.
- This can be expressed as R(A,B,C), C--->A where:
- The relation R contains attributes A, B and C.
- A and B form a candidate key.
- C is the determinant for A (A is functionally dependent on C).
- C is not part of any key.
- Anomalies can also occur where a relation contains several candidate keys where:
- The keys contain more than one attribute (they are composite keys).
- An attribute is common to more than one key.
Example to understand BCNF:-
Take the following table:
campus | course | class | time | room/bldg |
|---|
East
|
English 101
|
1
|
8:00-9:00
|
212 AYE
|
East
|
English 101
|
2
|
10:00-11:00
|
305 RFK
|
West
|
English 101
|
3
|
8:00-9:00
|
102 PPR
|
Note that no two buildings on any of the university campuses have the same name, thus ROOM/BLDG----->CAMPUS. As the determinant is not a candidate key this table is NOT in Boyce-Codd normal form.
This table should be decomposed into the following relations:
R1(course, class, room/bldg, time)
course | class | time | room/bldg |
|---|
English 101
|
1
|
8:00-9:00
|
212 AYE
|
English 101
|
2
|
10:00-11:00
|
305 RFK
|
English 101
|
3
|
8:00-9:00
|
102 PPR
|
R2(room/bldg, campus)
campus | room/bldg |
|---|
East
|
212 AYE
|
East
|
305 RFK
|
West
|
102 PPR
|
|