Third Normal Form (3NF)
3NF Definition
Read aloud is unavailable in this browser.
The Formal Foundation of 3NF
Having explored transitive dependencies and their destructive potential, we now arrive at Third Normal Form (3NF)—the normal form specifically designed to eliminate these indirect dependency chains while maintaining practical usability.
Third Normal Form represents a crucial milestone in database normalization. Unlike BCNF (which we'll study later), 3NF strikes a careful balance: it removes transitive dependencies on non-prime attributes while preserving functional dependencies through decomposition. This balance makes 3NF the most commonly used normal form in production database design.
By the end of this page, you will understand multiple equivalent definitions of 3NF, the relationship between 3NF and 2NF, the role of prime and non-prime attributes, and why 3NF remains the practical standard for most database designs. You'll be able to precisely determine whether any relation is in 3NF.
The Classic Definition of Third Normal Form
The original definition of Third Normal Form, proposed by E.F. Codd in 1971, is elegant in its simplicity:
Codd's Definition of 3NF:
A relation R is in Third Normal Form if and only if:
- R is in Second Normal Form (2NF), AND
- Every non-prime attribute of R is non-transitively dependent on every candidate key of R
This definition builds directly on what we learned about 2NF and transitive dependencies. Let's unpack each component:
- •R is in 2NF: The relation satisfies 1NF (atomic values, no repeating groups) AND has no partial dependencies (every non-prime attribute depends on the whole of every candidate key, not just part of it)
- •Non-prime attribute: An attribute that is NOT part of ANY candidate key. These are the "regular" attributes that describe entities
- •Non-transitively dependent: The attribute depends directly on the candidate key, not through some intermediate non-prime attribute. There's no chain K → Y → A where Y is non-prime
- •Every candidate key: The condition must hold for all candidate keys, not just the primary key. If any candidate key has transitive dependencies to non-prime attributes, 3NF is violated
3NF inherits all requirements from 2NF, which inherits all requirements from 1NF. Therefore: Every relation in 3NF is automatically in 2NF, and every relation in 2NF is automatically in 1NF. The normal forms form a strict hierarchy: 1NF ⊃ 2NF ⊃ 3NF.
In Simpler Terms:
A relation is in 3NF if:
- It has no repeating groups or non-atomic values (1NF satisfied)
- No attribute depends on only part of a candidate key (2NF satisfied)
- No attribute depends on another non-key attribute that depends on and doesn't determine a candidate key (3NF addition)
Or even simpler: Non-prime attributes must depend on the key, the whole key, and nothing but the key.
This famous mnemonic, often attributed to Bill Kent, captures 1NF, 2NF, and 3NF together:
- "The key" → 1NF: There is a key (no repeating groups)
- "The whole key" → 2NF: Depend on the complete key (no partial dependencies)
- "Nothing but the key" → 3NF: Depend only on the key (no transitive dependencies)
The Modern Definition of Third Normal Form
While Codd's original definition is historically important, database theory has evolved to express 3NF more directly. The modern definition doesn't require checking 2NF as a prerequisite—it captures everything in a single statement:
Modern Definition of 3NF:
A relation R with functional dependencies F is in Third Normal Form if and only if:
For every non-trivial functional dependency X → A in F⁺:
- X is a superkey, OR
- A is a prime attribute (A is part of some candidate key)
This definition is more general and powerful because it doesn't rely on the normal form hierarchy—it directly characterizes 3NF through properties of functional dependencies.
| Term | Definition | Example |
|---|---|---|
| Non-trivial FD | X → A where A ∉ X (A is not contained in X) | StudentID → Name is non-trivial; {A, B} → A is trivial |
| F⁺ (closure) | All FDs that can be derived from F using Armstrong's Axioms | If F = {A → B, B → C}, then F⁺ includes A → C |
| Superkey | An attribute set that functionally determines all other attributes | {StudentID} or {StudentID, Name} in a Student relation |
| Prime attribute | An attribute that appears in at least one candidate key | In R(A, B, C) with keys {A} and {B}, both A and B are prime |
Why This Definition is Equivalent:
Let's verify that the modern definition captures both 2NF and the 3NF transitive dependency condition:
Capturing 2NF (No Partial Dependencies):
- A partial dependency occurs when X → A where X is a proper subset of a candidate key
- If X is a proper subset of a key, X is NOT a superkey
- If A is not part of any candidate key (non-prime), we violate the modern 3NF condition
- Therefore, the modern definition automatically prevents partial dependencies
Capturing 3NF (No Transitive Dependencies on Non-Prime):
- A transitive dependency K → Y → A means Y → A exists where Y is not a superkey
- If A is non-prime, we have Y → A where Y is not a superkey and A is not prime
- This directly violates the modern 3NF condition
- Therefore, transitive dependencies to non-prime attributes are forbidden
Notice that transitive dependencies to prime attributes are allowed in 3NF! If A is part of a candidate key, then X → A is acceptable even if X is not a superkey. This is a key difference from BCNF, which requires X to be a superkey for ALL non-trivial FDs, regardless of whether A is prime.
Prime vs Non-Prime Attributes Deep Dive
The distinction between prime and non-prime attributes is central to understanding 3NF. Let's examine this distinction rigorously.
Definitions:
Prime Attribute: An attribute that is a member of at least one candidate key
Non-Prime Attribute: An attribute that is NOT a member of ANY candidate key
Note that an attribute can be prime by virtue of belonging to just one candidate key, even if it's not in others.
Identifying Prime and Non-Prime Attributes
Consider a Course Assignment relation
- •Relation: CourseAssignment(CourseID, ProfessorID, Semester, RoomNumber, ProfessorName, CourseName)
- •Business Rules:
- •• A course in a given semester has exactly one professor
- •• A professor can teach at most one course per semester
- •• Each course-semester assignment has one room
- •Candidate Keys Identified:
- •• {CourseID, Semester} — uniquely identifies assignment
- •• {ProfessorID, Semester} — also unique (one course per professor per semester)
- •Prime Attributes: CourseID, ProfessorID, Semester (all appear in at least one candidate key)
- •Non-Prime Attributes: RoomNumber, ProfessorName, CourseName (not in any candidate key)
| Relation | Candidate Keys | Prime Attributes | Non-Prime Attributes |
|---|---|---|---|
| Student(SID, SSN, Name, GPA) | {SID}, {SSN} | SID, SSN | Name, GPA |
| Enrollment(SID, CID, Grade) | {SID, CID} | SID, CID | Grade |
| Employee(EmpID, DeptID, Salary, DeptName) | {EmpID} | EmpID | DeptID, Salary, DeptName |
| Flight(FlightNo, Date, Pilot, CoPilot) | {FlightNo, Date} | FlightNo, Date | Pilot, CoPilot |
A primary key is always a candidate key, but not all candidate key attributes are in the primary key. An attribute is prime if it's in ANY candidate key, not just the primary key. When determining 3NF, you must consider ALL candidate keys.
Why the Distinction Matters for 3NF:
The 3NF definition treats prime and non-prime attributes differently:
-
Non-prime attributes must depend directly on a superkey. Any transitive dependency through a non-superkey intermediate violates 3NF.
-
Prime attributes can depend on non-superkey determinants. The reasoning is that dependencies involving prime attributes are "acceptable" because they participate in the key structure of the relation.
This asymmetry is what distinguishes 3NF from BCNF:
- 3NF: X → A violates 3NF only if X is not a superkey AND A is non-prime
- BCNF: X → A violates BCNF if X is not a superkey (regardless of A being prime or not)
3NF vs 2NF: A Detailed Comparison
While 3NF builds on 2NF, they address different classes of problematic dependencies. Understanding their relationship clarifies what each normal form accomplishes.
The Progression:
1NF: Ensures atomic values and proper relational structure 2NF: Removes partial dependencies (non-prime depends on part of key) 3NF: Removes transitive dependencies (non-prime depends on non-key)
- •Targets: Partial dependencies
- •Problem pattern: Subset of key → Non-prime attribute
- •Example violation: (StudentID, CourseID) → StudentName (via StudentID alone)
- •Relevant when: Composite keys exist
- •Automatically satisfied by: Relations with single-attribute keys
- •After achieving: All non-prime attributes depend on the whole key
- •Targets: Transitive dependencies
- •Problem pattern: Key → Non-prime → Non-prime
- •Example violation: EmpID → DeptID → DeptName (via DeptID)
- •Relevant when: Non-key determines non-key
- •Automatically satisfied by: Relations where all non-primes depend directly on keys
- •After achieving: All non-prime attributes depend on keys, not intermediates
Key Insight: Why 2NF Doesn't Imply 3NF
A relation can be in 2NF (no partial dependencies) but still have transitive dependencies. Consider:
Employee(EmpID, DeptID, DeptName, Salary)
- Primary Key: EmpID (single attribute—partial dependencies impossible)
- FDs: EmpID → DeptID, EmpID → Salary, DeptID → DeptName
2NF Check: ✓ Passes. With a single-attribute key, partial dependencies cannot exist.
3NF Check: ✗ Fails! EmpID → DeptID → DeptName is a transitive dependency. DeptID is not a superkey, and DeptName is non-prime.
This demonstrates that 2NF handles a different class of problem than 3NF. Both must be achieved for a well-designed relation.
When a relation has only single-attribute candidate keys (no composite keys), it's automatically in 2NF because partial dependencies cannot exist—you can't have a 'part' of a single-attribute key. However, such relations can still have transitive dependencies and thus violate 3NF.
Formal 3NF Test Procedure
To rigorously determine whether a relation is in Third Normal Form, follow this systematic procedure:
Algorithm: Test for 3NF
Input: Relation R(A₁, A₂, ..., Aₙ), Set of FDs F
Output: TRUE if R is in 3NF, FALSE otherwise (with violating FD)
1. Find all candidate keys of R
- Use attribute closure to identify minimal superkeys
2. Classify attributes as Prime or Non-Prime
- Prime: appears in at least one candidate key
- Non-Prime: all other attributes
3. For each non-trivial FD (X → A) in F (or F⁺):
a. Is X a superkey of R?
- If YES: This FD satisfies 3NF (continue to next FD)
b. Is A a prime attribute?
- If YES: This FD satisfies 3NF (continue to next FD)
c. If NEITHER: This FD violates 3NF
- Return FALSE with (X → A) as the violating FD
4. If all FDs pass: Return TRUE
Applying the 3NF Test
Testing relation R(A, B, C, D, E) with F = {A → B, BC → D, D → E}
- •Step 1: Find candidate keys
- •• Compute {A}⁺ = {A, B} (not all attributes)
- •• Compute {A, C}⁺ = {A, B, C, D, E} = R ✓ (superkey)
- •• Is {A, C} minimal? {A}⁺ ≠ R, {C}⁺ = {C} ≠ R. Yes, minimal
- •• Candidate key: {A, C}
- •Step 2: Classify attributes
- •• Prime: A, C
- •• Non-Prime: B, D, E
- •Step 3: Test each FD
- •• A → B: Is A superkey? No. Is B prime? No. ❌ VIOLATION!
- •Result: R is NOT in 3NF (A → B violates: A is not superkey, B is non-prime)
You don't always need to compute the full closure F⁺. Start by testing only the FDs explicitly in F. If all of those pass the 3NF test, the relation is in 3NF (because derived FDs inherit the property). Only compute additional derived FDs if you need to find candidate keys.
Comprehensive 3NF Test Examples
Let's work through several examples to solidify your understanding of the 3NF test procedure.
Example 1: Relation that Passes 3NF
Example 1: Student Relation (In 3NF)
R = Student(StudentID, Name, Email)
- •FDs: StudentID → Name, StudentID → Email
- •Candidate key: {StudentID} (determines all attributes)
- •Prime: StudentID
- •Non-Prime: Name, Email
- •Test FDs:
- •• StudentID → Name: StudentID is a superkey ✓
- •• StudentID → Email: StudentID is a superkey ✓
- •Result: ✅ In 3NF (all FDs have superkey determinants)
Example 2: Relation that Fails 3NF
Example 2: Order Relation (Violates 3NF)
R = Order(OrderID, CustomerID, CustomerName, ProductID, Quantity)
- •FDs: OrderID → CustomerID, CustomerID → CustomerName, OrderID → ProductID, OrderID → Quantity
- •Candidate key: {OrderID}
- •Prime: OrderID
- •Non-Prime: CustomerID, CustomerName, ProductID, Quantity
- •Test FDs:
- •• OrderID → CustomerID: OrderID is superkey ✓
- •• CustomerID → CustomerName: CustomerID is NOT superkey, CustomerName is NOT prime ❌
- •Result: ❌ NOT in 3NF (CustomerID → CustomerName violates)
- •Transitive chain: OrderID → CustomerID → CustomerName
Example 3: Relation with Multiple Candidate Keys
Example 3: Employee-Project (Multiple Keys)
R = Assignment(EmpID, EmpSSN, ProjectID, Hours)
- •FDs: EmpID → EmpSSN, EmpSSN → EmpID (bidirectional), {EmpID, ProjectID} → Hours
- •Candidate keys: {EmpID, ProjectID}, {EmpSSN, ProjectID} (equivalent employee identifiers)
- •Prime: EmpID, EmpSSN, ProjectID (all in at least one key)
- •Non-Prime: Hours
- •Test FDs:
- •• EmpID → EmpSSN: EmpID is NOT superkey, but EmpSSN IS prime ✓
- •• EmpSSN → EmpID: EmpSSN is NOT superkey, but EmpID IS prime ✓
- •• {EmpID, ProjectID} → Hours: {EmpID, ProjectID} is superkey ✓
- •Result: ✅ In 3NF (all FDs satisfy either superkey OR prime attribute condition)
Example 3 demonstrates how FDs like EmpID → EmpSSN don't violate 3NF because EmpSSN is prime. This same FD WOULD violate BCNF (because EmpID alone is not a superkey). This is why 3NF is sometimes called a 'relaxation' of BCNF.
Why 3NF is the Practical Standard
Third Normal Form has become the most widely used normal form in production database design. This isn't by accident—3NF achieves a crucial balance that makes it uniquely practical.
The Key Guarantee:
For any relation schema R and set of FDs F, there always exists a decomposition of R that is:
- In 3NF
- Lossless-join (no information lost)
- Dependency-preserving (all FDs can be checked within single relations)
This triple guarantee is remarkable. BCNF, which is "stricter" than 3NF, cannot always provide dependency preservation. Many real-world schemas must sacrifice dependency preservation to achieve BCNF, which has practical consequences for constraint enforcement.
| Property | 3NF | BCNF |
|---|---|---|
| Eliminates transitive dependencies on non-prime | ✓ Yes | ✓ Yes |
| Eliminates transitive dependencies on prime | ✗ No (allowed) | ✓ Yes |
| Lossless decomposition always possible | ✓ Yes | ✓ Yes |
| Dependency-preserving decomposition always possible | ✓ Yes | ✗ Not always |
| Easier to achieve | ✓ Yes | ✗ More restrictive |
| More redundancy possible | ✓ Slightly more | ✗ Minimal |
Why Dependency Preservation Matters:
When FDs are preserved in the decomposition, each FD can be enforced by checking a single relation. Consider:
- Preserved FD: CustomerID → CustomerName in Customer table. To verify, check only Customer.
- Lost FD: If decomposition splits attributes across tables, verifying the FD requires joining tables first, which is expensive and sometimes impractical in real-time enforcement.
For most applications, the ability to efficiently enforce constraints outweighs the marginal extra redundancy that 3NF allows compared to BCNF.
Industry Practice:
Most production databases target 3NF as their normalization goal:
- 3NF eliminates the most common and harmful redundancies
- Dependency preservation enables efficient constraint enforcement
- The allowed redundancy (transitive dependencies to prime attributes) is rare and low-impact
- Moving beyond 3NF typically offers diminishing returns for increased complexity
3NF typically eliminates 80%+ of data redundancy issues while preserving 100% of functional dependencies. Going to BCNF might eliminate slightly more redundancy but at the cost of dependency preservation and design complexity. For most use cases, 3NF is the optimal stopping point.
KEEP LEARNING
There’s more to understand.
You’re reading the introduction. Create a free account to read the complete lesson, save notes and keep track of your progress.