Introduction

A relation that stores two independent facts in one row repeats one of them, and repetition causes anomalies. In STUDENT_DEPT(roll, name, dept, hod), the head of department is stored once per student: changing the head means updating many rows (update anomaly), a department with no student cannot record its head (insertion anomaly), and deleting the last student of a department loses its head (deletion anomaly).

After 1NF's atomic-domain condition, the 2NF, 3NF and BCNF conditions here are FD-based and progressively stronger, ruling out the corresponding redundancies. The definitions, a reliable test procedure, how to find the highest normal form of a relation from its FDs, and which decomposition reaches a target form are the standard facts.

Prerequisites

Core concepts

Let RR have FD set FF. An FD X→AX \to A is nontrivial if A∉XA \notin X. An attribute is prime if it belongs to some candidate key.

Normal formCondition
1NFevery attribute value is atomic (no sets, lists or nested relations)
2NF1NF, and no non-prime attribute is functionally dependent on a proper subset of any candidate key (no partial dependency)
3NFfor every nontrivial X→AX \to A in F+F^+: XX is a superkey or AA is prime
BCNFfor every nontrivial X→AX \to A in F+F^+: XX is a superkey

Equivalent form of 3NF. RR is in 3NF iff no non-prime attribute is transitively dependent on a candidate key, that is, there is no chain key →X→A\to X \to A with XX not a superkey, AA non-prime, and A∉XA\notin X (the last FD must be nontrivial).

Inclusions. BCNF ⊂\subset 3NF ⊂\subset 2NF ⊂\subset 1NF, and each inclusion is strict.

Four nested regions: 1NF outermost, then 2NF, 3NF and BCNF innermost, each labelled with its condition and an example relation that is in that form but not the next
Figure 1. The normal forms as nested classes, with one relation in each band: R(A,B,C,D)R(A, B, C, D) with AB→CDAB \to CD, B→CB \to C is only in 1NF; with A→BA \to B, B→CB \to C, C→DC \to D it is in 2NF; R(A,B,C)R(A, B, C) with AB→CAB \to C, C→BC \to B is in 3NF; with A→BCA \to BC it is in BCNF.

How it works: finding the highest normal form

  1. Find all candidate keys and the prime attributes.
  2. BCNF: for every FD X→YX \to Y of the given FF (nontrivial part only), check that X+=RX^+ = R. If all pass, the relation is in BCNF.
  3. 3NF: for every FD X→AX \to A of FF (split right sides) that failed step 2, check whether AA is prime. If every failure has a prime AA, the relation is in 3NF.
  4. 2NF: for every candidate key KK and every proper subset S⊂KS \subset K, check whether S+S^+ contains a non-prime attribute not in SS. If none does, the relation is in 2NF.
  5. Otherwise it is in 1NF (assuming atomic values).

Testing with FF instead of F+F^+. For the relation RR itself, steps 2 and 3 may use the given FF: if some FD of F+F^+ violates BCNF or 3NF, some FD of FF does too. This shortcut is not valid for a sub-relation RiR_i of a decomposition: there the FDs that hold are the projection of F+F^+ onto RiR_i, which can contain FDs that appear in no member of FF. The next note shows an instance.

Algorithms and pseudocode

Text
HIGHEST-NF(R, F)
  K <- CANDIDATE-KEYS(R, F); P <- union of the keys     // prime attributes
  bcnf <- true; third <- true
  for each X -> A in F with A not in X
      if CLOSURE(X, F) != R then
          bcnf <- false
          if A not in P then third <- false
  if bcnf then return "BCNF"
  if third then return "3NF"
  for each key k in K, for each proper subset S of k
      if (CLOSURE(S, F) - S) contains an attribute not in P then return "1NF"
  return "2NF"

Cost is dominated by finding candidate keys, exponential in the worst case; each closure is polynomial.

Mathematical explanation

Why the inclusions hold. BCNF implies 3NF because its condition is the first disjunct of the 3NF condition. 3NF implies 2NF: a partial dependency S→AS \to A with S⊂KS \subset K and AA non-prime is a nontrivial FD whose left side SS is not a superkey (a proper subset of a candidate key cannot be a superkey, by minimality) and whose right side is non-prime, so it violates 3NF.

Useful sufficient conditions. The singleton-key and two-attribute shortcuts below, including their repetitions in examples, traps and the summary, assume no nontrivial empty-determinant (constant) dependencies. Without that assumption, test the empty subset too using the general definitions.

  • Assuming no nontrivial empty-determinant FDs, if every candidate key is a single attribute, the relation is in 2NF (a single attribute has no non-empty proper subset).
  • If every attribute is prime, the relation is in 3NF (the second disjunct always holds).
  • With no nontrivial empty-determinant FDs, every relation with exactly two attributes is in BCNF: any nontrivial FD is A→BA \to B or B→AB \to A, and then its left side determines both attributes.

Why 3NF exists alongside BCNF. Some relations have no BCNF decomposition that preserves all dependencies (the relation R(A,B,C)R(A, B, C) with AB→CAB \to C, C→BC \to B is the standard case), while a dependency-preserving, lossless 3NF decomposition always exists. 3NF is the compromise that tolerates a little redundancy to keep every FD checkable in one table.

Worked examples

#Relation and FDsCandidate keysHighest formReason
1R(A,B,C,D)R(A, B, C, D); AB→CDAB \to CD, B→CB \to CABAB1NFB→CB \to C is partial (CC non-prime)
2R(A,B,C,D)R(A, B, C, D); A→BA \to B, B→CB \to C, C→DC \to DAA2NFsingle-attribute key; B→CB \to C transitive
3R(A,B,C,D)R(A, B, C, D); AB→CAB \to C, C→DC \to DABAB2NFno partial FD; C→DC \to D transitive
4R(A,B,C)R(A, B, C); AB→CAB \to C, C→BC \to BABAB, ACAC3NFCC not a superkey but BB prime
5R(A,B,C,D,E)R(A, B, C, D, E); A→BA \to B, BC→EBC \to E, ED→AED \to AACDACD, BCDBCD, CDECDE3NFall attributes prime; A→BA \to B breaks BCNF
6R(A,B,C,D,E,G)R(A, B, C, D, E, G); BE→GBE \to G, D→ED \to E, AB→CAB \to C, C→DC \to D, G→AG \to AABAB, BCBC, BDBD, BEBE, BGBG3NFall prime; D→ED \to E breaks BCNF
7R(A,B,C)R(A, B, C); A→BCA \to BCAABCNFthe only left side is a key

Example 8: the anomaly relation. STUDENT_DEPT(roll, name, dept, hod) with roll →\to name, dept and dept →\to hod. Key: roll. Single-attribute key, so 2NF; dept →\to hod has a non-superkey left side and non-prime right side, so not 3NF. Splitting into (roll, name, dept) and (dept, hod) gives two BCNF relations and removes all three anomalies.

Example 9: a partial dependency on a prime attribute is allowed in 2NF. In Example 4, C→BC \to B has left side CC, a proper subset of key ACAC, but BB is prime, so it is not a 2NF violation (and the relation is even in 3NF).

Example 10: three overlapping keys. R(A,B,C,D)R(A, B, C, D) with AB→CAB \to C, C→DC \to D, D→AD \to A.

  • BB is on no right side, so it is in every key. B+=BB^+ = B.
  • (AB)+=ABCD(AB)^+ = ABCD, (BC)+=BCDA(BC)^+ = BCDA, (BD)+=ABCD(BD)^+ = ABCD. So ABAB, BCBC, BDBD are keys, and every attribute is prime.
  • 3NF holds because every right side is prime. BCNF fails: C+=ACDC^+ = ACD, so C→DC \to D has a non-superkey left side.
  • The three keys pairwise share BB: 3NF without BCNF happens only when candidate keys overlap.

Example 11: the chosen primary key hides a partial dependency. R(A,B,C,D,E)R(A, B, C, D, E) with A→BCDEA \to BCDE, BC→ABC \to A, C→DC \to D.

  • A+=ABCDEA^+ = ABCDE, so AA is a key. (BC)+=ABCDE(BC)^+ = ABCDE, and neither B+=BB^+ = B nor C+=CDC^+ = CD is RR, so BCBC is also a key. Candidate keys: AA, BCBC. Prime attributes: AA, BB, CC.
  • C→DC \to D: CC is a proper subset of the candidate key BCBC and DD is non-prime. That is a partial dependency, so the relation is not in 2NF; the highest form is 1NF.
  • If only the primary key AA is examined, the relation looks like 2NF because AA has no proper subset. The 2NF test runs over every candidate key.

Important properties and observations

  • Only non-prime attributes matter for 2NF and 3NF; BCNF ignores primality.
  • Two-attribute relations are always in BCNF.
  • A relation whose only key is all its attributes (no nontrivial FD) is in BCNF.
  • Check all candidate keys, not only the primary key, when deciding primality and partial dependency.
  • Test on FF for the whole relation; on the projection of F+F^+ for a sub-relation.
  • Normal form is a property of the schema with its FDs, not of one instance.

Related material. Fourth normal form (4NF) uses multivalued dependencies X↠YX \twoheadrightarrow Y: a relation is in 4NF if every nontrivial MVD has a superkey on the left. It removes redundancy that FDs cannot describe, such as an employee's independent sets of skills and languages stored in one table. 5NF uses join dependencies.

Common misconceptions.

  • "3NF means no transitive dependency at all." Only no transitive dependency of a non-prime attribute.
  • "If the primary key is a single attribute, the relation is in 3NF." Not even 2NF is guaranteed: 2NF needs every candidate key to be a single attribute (or no partial dependency on a composite one), as Example 11 shows. With no constant dependencies, every candidate key being a singleton guarantees 2NF, but not 3NF; otherwise test empty subsets too.
  • "BCNF and 3NF differ only when there are composite keys." They differ when a non-superkey determines a prime attribute, which needs overlapping candidate keys.

GATE examination perspective

  • Highest normal form. Keys first, then BCNF, 3NF, 2NF tests in that order.
  • Prime attributes from overlapping keys. Relations where every attribute is prime are at least 3NF.
  • Partial versus transitive dependency. Classify a given FD as the cause of a 2NF or 3NF violation.
  • Which FD set makes the relation BCNF. Pick the option where every nontrivial FD has a superkey on its left side.
  • Anomalies. Recognise which anomaly a given redundancy causes.

Summary

Sources

  1. A. Silberschatz, H. F. Korth, S. Sudarshan, Database System Concepts, 7th ed., McGraw-Hill, 2019 (2020 copyright), 7.1 Features of Good Relational Designs, 7.3 Normal Forms, 7.8 Atomic Domains and First Normal Form.
  2. R. Elmasri, S. B. Navathe, Fundamentals of Database Systems, 7th ed., Pearson, 14.1 Informal Design Guidelines for Relation Schemas; 14.3 Normal Forms Based on Primary Keys; 14.4 General Definitions of Second and Third Normal Forms; 14.5 Boyce-Codd Normal Form; 14.6 Multivalued Dependency and Fourth Normal Form.

Next steps