Second Normal Form: Eliminating Partial Dependencies
Second Normal Form: The Formal Definition
Read aloud is unavailable in this browser.
From Concept to Formalism
In the previous page, we developed an intuitive understanding of partial dependencies—what they are, why they occur, and the damage they cause. Now we elevate that intuition to mathematical precision.
Second Normal Form (2NF) was introduced by E.F. Codd in 1971 as part of his pioneering work on relational database theory. It represents the second level in the normalization hierarchy, building upon First Normal Form and addressing a specific class of redundancy problems: those caused by partial dependencies.
By the end of this page, you will understand the precise definition of 2NF, its prerequisites, the relationship between 2NF and 1NF, how to formally verify whether a relation is in 2NF, and why 2NF specifically targets composite key scenarios. You will be able to apply this definition to any relation with confidence.
The Formal Definition of Second Normal Form
Let's state the definition with complete mathematical rigor:
Definition: Second Normal Form (2NF)
A relation R is in Second Normal Form if and only if:
- R is in First Normal Form (1NF), AND
- Every non-prime attribute of R is fully functionally dependent on every candidate key of R
Equivalently, a relation is in 2NF if:
- It is in 1NF, AND
- It has NO partial dependencies (no non-prime attribute depends on a proper subset of any candidate key)
Prime attribute: An attribute that is part of at least one candidate key. Non-prime attribute: An attribute that is not part of any candidate key. Full functional dependency: X → A where no proper subset of X determines A. Partial functional dependency: X → A where some proper subset of X also determines A.
Breaking Down the Definition:
The definition has two parts, both of which must be satisfied:
Part 1: 1NF Prerequisite
Before checking for 2NF, the relation must already be in 1NF. This means:
- All attributes must have atomic values (no repeating groups, no multi-valued attributes)
- Each cell contains exactly one value
- There is a defined primary key
Part 2: No Partial Dependencies
This is the core requirement unique to 2NF. For every non-prime attribute A in the relation:
- A must depend on the COMPLETE candidate key
- No proper subset of any candidate key should determine A
- The dependency must be "full" not "partial"
This requirement applies to EVERY candidate key, not just the primary key. If a relation has multiple candidate keys, the non-prime attributes must be fully dependent on ALL of them.
When 2NF Is Automatically Satisfied
There are important special cases where a relation is AUTOMATICALLY in 2NF without further analysis:
Case 1: Single-Attribute Candidate Keys
If all candidate keys consist of single attributes, the relation is automatically in 2NF (assuming it's in 1NF).
Why? Partial dependencies require depending on a PROPER SUBSET of the key. If the key has only one attribute, the only proper subset is the empty set, and no attribute can depend on nothing. Therefore, partial dependencies are mathematically impossible.
| Scenario | Key Structure | 2NF Status | Reason |
|---|---|---|---|
| Employee(EmpID, Name, Dept) | Single attribute: {EmpID} | ✓ Auto-2NF | No proper subset possible |
| Product(SKU, Name, Price) | Single attribute: {SKU} | ✓ Auto-2NF | No proper subset possible |
| Order(OrderID, Date, Total) | Single attribute: {OrderID} | ✓ Auto-2NF | No proper subset possible |
| Enrollment(SID, CID, Grade) | Composite: {SID, CID} | Must check | Proper subsets exist |
Case 2: All Attributes Are Prime
If every attribute in the relation is part of some candidate key (i.e., there are NO non-prime attributes), the relation is automatically in 2NF.
Why? The 2NF definition specifically concerns non-prime attributes. If there are no non-prime attributes, there's nothing that can have a partial dependency.
Example:
Meeting(RoomID, TimeSlot, MeetingID)
Candidate Keys: {RoomID, TimeSlot} and {MeetingID}
All three attributes are prime (each appears in at least one candidate key), so there are no non-prime attributes to check. The relation is automatically in 2NF.
Before deep-diving into partial dependency analysis, ask: 'Is the key composite?' and 'Are there non-prime attributes?' If the answer to either is 'no', you can often conclude 2NF is satisfied immediately.
Formal Verification Procedure
To rigorously determine whether a relation is in 2NF, follow this systematic procedure:
Algorithm: 2NF Verification
Systematic 2NF Check
- •Verify 1NF: Confirm the relation satisfies all 1NF requirements (atomic values, no repeating groups, primary key defined).
- •Identify all candidate keys: List every candidate key for the relation. Pay attention to composite keys.
- •Quick exit check: If ALL candidate keys are single-attribute, STOP — the relation is in 2NF.
- •Identify prime attributes: List all attributes appearing in at least one candidate key.
- •Identify non-prime attributes: List all attributes NOT appearing in any candidate key.
- •Quick exit check: If there are NO non-prime attributes, STOP — the relation is in 2NF.
- •For each composite candidate key K: Enumerate all proper subsets of K.
- •For each non-prime attribute A: Check if any proper subset of K determines A.
- •Conclude: If ANY partial dependency exists, the relation is NOT in 2NF. Otherwise, it IS in 2NF.
Worked Example: Full Verification
Relation: ProjectAssignment(EmpID, ProjID, EmpName, ProjName, HoursWorked)
Step 1: Verify 1NF ✓
- All values are atomic
- Primary key is {EmpID, ProjID}
Step 2: Candidate Keys
- {EmpID, ProjID} is the only candidate key (composite)
Step 3: Quick Exit — FAILS (key is composite, proceed)
Step 4: Prime Attributes
- EmpID, ProjID
Step 5: Non-Prime Attributes
- EmpName, ProjName, HoursWorked
Step 6: Quick Exit — FAILS (non-prime attributes exist, proceed)
Step 7: Proper Subsets of Key
- {EmpID}
- {ProjID}
Step 8: Check Dependencies
| Non-Prime Attribute | {EmpID} → ? | {ProjID} → ? | Verdict |
|---|---|---|---|
| EmpName | YES | NO | Partial Dep! |
| ProjName | NO | YES | Partial Dep! |
| HoursWorked | NO | NO | Full Dep ✓ |
Step 9: Conclusion
Partial dependencies exist:
- {EmpID} → EmpName
- {ProjID} → ProjName
The relation is NOT in 2NF.
When a relation has multiple candidate keys, you must check for partial dependencies against EACH composite candidate key. A relation is only in 2NF if no partial dependencies exist for ANY of its candidate keys.
2NF in the Normal Form Hierarchy
Understanding where 2NF fits in the normalization hierarchy clarifies its role and limitations:
The Normalization Ladder:
┌─────────────────────────────────────┐ │ 5NF (PJNF) │ Most restrictive │ No join dependencies │ └───────────────┬─────────────────────┘ │ ┌───────────────▼─────────────────────┐ │ 4NF │ │ No multivalued dependencies │ └───────────────┬─────────────────────┘ │ ┌───────────────▼─────────────────────┐ │ BCNF │ │ Every determinant is candidate key│ └───────────────┬─────────────────────┘ │ ┌───────────────▼─────────────────────┐ │ ★ 3NF ★ │ │ 2NF + No transitive dependencies │ └───────────────┬─────────────────────┘ │ ┌─────────────────────────▼─────────────────────────────┐ │ ★ 2NF ★ │ │ 1NF + No partial dependencies │ │ Every non-prime fully depends on every candidate key│ └─────────────────────────┬─────────────────────────────┘ │ ┌───────────────▼─────────────────────┐ │ 1NF │ │ Atomic values, primary key defined│ └───────────────┬─────────────────────┘ │ ┌───────────────▼─────────────────────┐ │ Unnormalized │ Least restrictive │ May have repeating groups │ └─────────────────────────────────────┘Key Relationships:
2NF ⊂ 1NF: Every relation in 2NF is also in 1NF (by definition, 2NF requires 1NF)
3NF ⊂ 2NF: Every relation in 3NF is also in 2NF (3NF adds additional constraints)
BCNF ⊂ 3NF (with some nuance): Generally, BCNF is stricter than 3NF
Implication:
If you achieve 3NF or higher, you automatically have 2NF. However, when normalizing step-by-step, achieving 2NF is a necessary intermediate step. You cannot jump directly from 1NF to 3NF without passing through 2NF conditions.
2NF addresses: Redundancy caused by non-prime attributes depending on parts of composite keys (partial dependencies).
2NF does NOT address: Redundancy caused by non-prime attributes depending on other non-prime attributes (transitive dependencies—addressed by 3NF).
2NF and Relation Decomposition
When a relation violates 2NF, the remedy is decomposition—breaking the relation into smaller relations that each satisfy 2NF. Understanding the relationship between 2NF and decomposition is crucial.
The Decomposition Principle:
For each partial dependency X → A (where X is a proper subset of the key and A is a non-prime attribute):
- Create a new relation containing X and A (where X is the key)
- Remove A from the original relation
This process is repeated until no partial dependencies remain.
Preview Example:
Original relation NOT in 2NF:
StudentCourse(StudentID, CourseID, StudentName, CourseName, Grade)
Partial Dependencies:
{StudentID} → StudentName
{CourseID} → CourseName
Decomposition to achieve 2NF:
Student(StudentID, StudentName)
Key: {StudentID}
Course(CourseID, CourseName)
Key: {CourseID}
Enrollment(StudentID, CourseID, Grade)
Key: {StudentID, CourseID}
Each resulting relation is now in 2NF:
- Student: Single-attribute key, automatically 2NF
- Course: Single-attribute key, automatically 2NF
- Enrollment: All non-prime attributes (Grade) fully depend on the complete key
Good decomposition should be: 1. Lossless: No information is lost; we can reconstruct the original relation via joins. 2. Dependency Preserving: Functional dependencies can still be enforced without joins.
We'll explore decomposition techniques in detail in a later page.
Common Misconceptions About 2NF
Let's address common misunderstandings that can lead to incorrect 2NF analysis:
- •"2NF means no redundancy at all"
- •"A relation with a single-column key might violate 2NF"
- •"All attributes must depend on the primary key"
- •"2NF applies only to the primary key"
- •"If there's any dependency, it's a 2NF violation"
- •2NF only eliminates partial dependency redundancy; transitive dependencies may remain
- •Single-column keys CANNOT have partial dependencies—2NF is automatic
- •Prime attributes can depend on other prime attributes—that's allowed
- •2NF must be checked against ALL candidate keys, not just primary
- •Only PARTIAL dependencies on NON-PRIME attributes violate 2NF
Subtle Point: Prime vs Non-Prime
A frequent source of confusion is the focus on NON-PRIME attributes. The 2NF definition specifically says:
"Every non-prime attribute is fully functionally dependent on every candidate key"
Prime attributes are exempt from this requirement. If a prime attribute (one that's part of some candidate key) depends on a proper subset of another candidate key, this is NOT a 2NF violation.
Example:
Relation: R(A, B, C)
Candidate Keys: {A, B} and {C}
Functional Dependencies: C → A
Here, A is a prime attribute (part of candidate key {A, B}). The dependency C → A means A depends on C, which is a proper subset of the key {A, B}. But this does NOT violate 2NF because A is prime.
However, this might violate BCNF, which has stricter requirements. The distinction matters when doing precise normalization analysis.
Mathematical Foundation
For those who appreciate formal rigor, let's express the 2NF definition using set notation and first-order logic:
Formal Definition using Set Notation:
Let R be a relation schema with:
- Set of attributes: U = {A₁, A₂, ..., Aₙ}
- Set of functional dependencies: F
- Set of candidate keys: CK = {K₁, K₂, ..., Kₘ}
Define:
- Prime attributes: P = ∪ᵢ Kᵢ (union of all candidate key attributes)
- Non-prime attributes: NP = U \ P (attributes not in any candidate key)
R is in 2NF if and only if:
∀A ∈ NP, ∀K ∈ CK where |K| ≥ 2: (K → A ∈ F⁺) ∧ (∄S ⊂ K : S → A ∈ F⁺)
Where F⁺ denotes the closure of F (all dependencies derivable from F using Armstrong's axioms).
Logical Formulation:
Another way to express 2NF:
R is in 2NF ⟺ R is in 1NF ∧ ¬∃(A, K, S) where:
- A ∈ NP (A is non-prime)
- K ∈ CK (K is a candidate key)
- S ⊂ K ∧ S ≠ ∅ (S is a proper, non-empty subset of K)
- S → A holds (S determines A)
In words: "There is no non-prime attribute determined by a proper non-empty subset of any candidate key."
Closure-Based Test:
To check if a partial dependency X → A exists (where X is a proper subset of some candidate key K):
- Compute X⁺ (the attribute closure of X under F)
- If A ∈ X⁺, then X → A holds
- If X is a proper subset of K and A is non-prime, we have a 2NF violation
The attribute closure algorithm (X⁺) from Chapter 18 is directly applicable here. To test if a partial dependency exists, compute the closure of the suspected partial determinant and check if the non-prime attribute is included.
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.