Canonical cover and normal forms: 1NF, 2NF, 3NF, BCNF
You learn to drop extraneous attributes to find the canonical cover, and to determine step by step which normal form a schema is in. The recipe for the 'What is the highest normal form?' question is on this page.
Last week you saw closure and finding keys. This week you use them to do two things: reduce an FD set to its simplest form (canonical cover) and find the highest normal form of a schema. The question “What is the highest normal form of R?” is almost guaranteed in the exam. The recipe is always the same:
- Find all candidate keys.
- Write the prime attributes: those that appear in at least one candidate key.
- Test every non-trivial FD in turn against BCNF, 3NF and 2NF.
Canonical cover
There can be many FD sets that carry the same information. The canonical cover is a set that is equivalent to (the same ) but contains nothing superfluous:
- No FD has an extraneous attribute.
- Every left side is unique (use instead of and ).
The extraneous attribute test
| Where | Question | Test |
|---|---|---|
| Left side: B in | Does A alone determine C? | Compute under the original F. Is C in it? |
| Right side: C in | Can I derive C without this FD? | Change the FD to . Does under the new set contain C? |
PITFALL · under which F? In the left-side test, the closure is taken with the unchanged F. In the right-side test, you put the shortened FD into the set and take the closure. Mixing the two leads to wrong “extraneous” decisions.
Worked example
1) Split the right sides: A -> B, A -> D, AB -> C, C -> D, B -> D
2) Left sides: is B extraneous in AB -> C?
{A}+ (under F): A -> B, A -> D, AB -> C → ABCD C is there → B is extraneous
is A extraneous? {B}+ = BD, no C → it is not
FD: A -> C
3) Redundant FDs: if A -> D is removed: {A}+ = A -> B, A -> C, C -> D → ABCD D is there → remove
if B -> D is removed: {B}+ = B, no D → needed
if C -> D is removed: {C}+ = C, no D → needed
if A -> B is removed: {A}+ = ACD, no B → needed
if A -> C is removed: {A}+ = ABD, no C → needed
4) Combine: Fc = { A -> BC, B -> D, C -> D }
Final check: is equivalent to ? Every FD in can be derived from , and the reverse holds too. Equivalent.
TIP · the canonical cover is not unique. If you do the redundancy tests in a different order, you may find a different but equivalent . If you write your steps in the exam, both answers are accepted. The examples on this page were solved in order from left to right.
First normal form (1NF)
A schema is in 1NF if the domain of every attribute is atomic: no list, set or repeating group in a cell.
| stu_id | name | phones |
|---|---|---|
| S1 | Ada | 0532 111 22 33, 0216 444 55 66 |
This table is not in 1NF. Fix: a separate table student_phone(stu_id, phone), with each phone in its own row. In the relational model every table is assumed to be in 1NF by default; the following forms look at FDs.
Second normal form (2NF)
1NF + no non-prime attribute depends on a proper subset of a candidate key. This forbidden situation is called a partial dependency.
University example: takes_wide(stu_id, course_id, grade, stu_name, title), with FDs , , .
The only key is {stu_id, course_id}. stu_name depends only on stu_id, and title only on course_id. Both are partial dependencies: highest 1NF. The update anomaly of last week’s wide table came from exactly this.
Example with letters: , . The key is AB, and is partial: 1NF.
PITFALL · a single-attribute key. If all candidate keys are single attributes, a partial dependency is impossible; if the schema is in 1NF, it is automatically in 2NF. In that case skip the 2NF test and go straight to 3NF.
Third normal form (3NF)
For every non-trivial , at least one of the following must be true:
- is a superkey, or
- is a prime attribute.
The typical violating case is a transitive dependency: key → non-key → non-key.
University example: student_dept(stu_id, name, dept_name, building), with FDs , . The key is stu_id (a single attribute, so 2NF is automatic). : dept_name is not a superkey, and building is not prime. 3NF is violated: highest 2NF.
Example with letters: , : the key is A, is transitive, 2NF.
Boyce-Codd normal form (BCNF)
For every non-trivial , must be a superkey. There is no “or A is prime” escape route as in 3NF. Every BCNF schema is in 3NF; the reverse is not always true.
The classic case that is in 3NF but not in BCNF: a non-key attribute determines part of a key. University example: tutoring(stu_id, subject, tutor_id). The rules: each tutor handles a single subject, and each student works with a single tutor for each subject.
The keys: {stu_id, subject} and {stu_id, tutor_id}. All three attributes are prime. : tutor_id is not a superkey, a BCNF violation. But subject is prime, so 3NF holds. Highest 3NF.
The version with letters: , , keys AB and AC, result 3NF.
All together: a worked determination
, .
Keys: A is not on the right → in every key
{A}+ = A
{A,B}+ = ABCDE key
{A,C}+: C -> D, D -> B, AB -> CDE = ABCDE key
{A,D}+: D -> B, AB -> CDE = ABCDE key
{A,E}+ = AE not a key
Prime: A, B, C, D (E is not prime)
AB -> CDE AB is a superkey BCNF ok
C -> D C is not a superkey BCNF violation; D is prime → 3NF ok
D -> B D is not a superkey BCNF violation; B is prime → 3NF ok
Result: 3NF (not BCNF)
One more BCNF example: , . and are both ABCD: every left side is a superkey, BCNF. The university’s course(course_id, title, dept_name, credits) and department(dept_name, building, budget) tables are in BCNF for the same reason: their only FDs come from the key.
PITFALL · looking only at F in the pieces. When you test the whole schema, looking at the FDs in F is enough. But when you test a decomposed piece, you have to think of the projection of onto that piece: FDs that come through an intermediate attribute not visible in the piece count too. We will use this next week.
Summary table of normal forms
| Form | Condition | What breaks it |
|---|---|---|
| 1NF | Atomic values | A list, a repeating group |
| 2NF | 1NF + no partial dependency | Part of a key → non-prime |
| 3NF | Every : X is a superkey or A is prime | Non-key → non-prime |
| BCNF | Every : X is a superkey | Non-superkey → anything |
Common mistakes
| Wrong idea | The truth |
|---|---|
| Not looking at the keys before finding the normal form | First all candidate keys and prime attributes |
| “A is prime” = A is in the primary key | Appearing in any candidate key is enough |
| 3NF and BCNF are the same | In 3NF a prime right side is allowed; in BCNF it is not |
| Several candidate keys break BCNF | AB and CD can be two keys, and the schema is still BCNF |
| Doing the left-side extraneous test with the modified F | Take under the original F |
| The canonical cover is unique | Different but equivalent results can come out depending on the order |
| If 2NF is broken, it can still be 3NF | The forms are nested: every 3NF schema is in 2NF |
Test yourself
Exam-style questions. Solve them on paper first, then reveal the answer.
A table student(stu_id, name, phones) stores values like '0532 111 22 33, 0216 444 55 66' in phones. Which normal form does it violate, and what is the usual fix?
Show answer
1NF requires a single, indivisible (atomic) value in each cell. A comma-separated list holds several values. Fix: a separate row for each phone, in a separate table: student_phone(stu_id, phone), with key (stu_id, phone).
Let . Is extraneous in ? Give the canonical cover.
Show answer
To test whether B on the left side is extraneous, drop B and compute under the original F: with we get {A,B}, with {A,B,C}. C is in it, so B is extraneous. The FD becomes . Combine the same left sides: .
Let . Which attribute is extraneous, and what is the canonical cover?
Show answer
Test C on the right side: put in place of ; under the new set , . C still comes out, so it is extraneous. Canonical cover: , .
Find a canonical cover of .
Show answer
1) Split the right sides: A→C, AC→D, E→A, E→D, E→H.
2) Is C extraneous in AC→D? = {A,C,D} (A→C, then AC→D). Yes: A→D.
3) Redundant FD: if E→D is removed, still contains D via E→A, A→C, A→D. E→D is redundant. The others are needed.
4) Combine: A→CD, E→AH. Check: the new set is equivalent to the original.
Let with . What is the highest normal form of ?
Show answer
A and B are not on the right, = ABCD: the only key is AB. The prime attributes are A, B. For : B is a proper subset of the key and D is not prime. There is a partial dependency, which breaks 2NF. Highest: 1NF.
Let with . What is the highest normal form?
Show answer
The key is a single attribute: A ( = ABCDE). A single-attribute key has no proper subset, so there can be no partial dependency: 2NF. But in , B is not a superkey and C is not prime: a transitive dependency, which breaks 3NF. The answer is 2NF.
Let with . Is in BCNF? Is it in 3NF?
Show answer
Keys: A is not on the right. {A,B}+ = ABC, {A,C}+ = ABC: the keys are AB, AC. For : C is not a superkey, which violates BCNF. For 3NF there is a second chance: is B prime? B is in the key AB, yes. All FDs satisfy the 3NF condition: 3NF but not BCNF.
Let with . What is the highest normal form?
Show answer
= ABCD, = ABCD. The left sides of both FDs are superkeys. The BCNF condition holds for every FD. The keys are A and BC.
Let with . Find all candidate keys and the highest normal form.
Show answer
A is not on the right, so it is in every key. {A}+ = A. AB: everything. AC: C→D, D→B, then AB→CDE, everything. AD: D→B, AB→CDE, everything. AE: {A,E}, not a key. The keys are AB, AC, AD; the prime attributes are A, B, C, D.: C is not a superkey, a BCNF violation, but D is prime. : B is prime. In AB→CDE the left side is a superkey. Every FD satisfies 3NF: 3NF, not BCNF.
Let with . What is the highest normal form?
Show answer
A, B are not on the right; {A,B}+ = ABCDE, the only key is AB. : B, a proper subset of the key, determines the non-prime E. A partial dependency: not 2NF. ( would also break 3NF, but there is no 2NF anyway.)
Let with . What is the highest normal form?
Show answer
= ABCD and = ABCD. The left sides of both FDs are superkeys. BCNF. There are two candidate keys: AB, CD. Having more than one key does not break BCNF.
True or false: every relation schema with exactly two attributes is in BCNF.
Show answer
For R(A,B) the possible non-trivial FDs are and . If holds, {A}+ = AB and A is a superkey. The same goes for . If there is no FD, the key is AB. In every case the left side is a superkey: BCNF.
Verification: All canonical covers, extraneous-attribute tests, candidate keys and normal form results were computed with verify/SEN2104/lib.mjs (canonicalCover, closure, equivalent, candidateKeys, highestNF; FD projection over all subsets) (verify/SEN2104/10.mjs, 43 checks, 0 errors).