NF

Database normalization can be defined mathematically using functional dependencies (FDs), superkeys, candidate keys, and attribute closures. Each normal form imposes specific conditions on a relation to reduce redundancy and prevent anomalies.

1. Mathematical foundations

Let R be a relation schema with attributes

R(A1,A2,…,An)

Let F be a set of functional dependencies that hold on R.

Functional dependency (FD)

A functional dependency X→Y holds if, for every valid instance r(R), any two tuples agreeing on attributes X must also agree on attributes Y.

∀t1,t2∈r,t1[X]=t2[X]⟹t1[Y]=t2[Y]

Example: If each student ID identifies exactly one student name,

StudentID→StudentName

Superkey and candidate key

A set of attributes K⊆R is a superkey if it functionally determines every attribute in R:

K→R

A candidate key is a minimal superkey:

K→R∧∀K′⊊K,K′↛R

A candidate key contains no unnecessary attribute.

Attribute closure

The closure X+ is the set of all attributes functionally determined by X, using the dependencies in F.

X+={A∈R∣F⊨X→A}

Thus:

A prime attribute belongs to at least one candidate key. A non-prime attribute belongs to no candidate key.

2. First Normal Form (1NF)

A relation is in 1NF if every attribute contains a single value from its domain in each tuple, rather than a collection of values or a repeating group.

Informally, attributes are atomic.

Example of a violation:

StudentID PhoneNumbers
1 9876, 8765
2 7654

PhoneNumbers contains multiple values in one cell.

A 1NF design could separate the numbers:

StudentID PhoneNumber
1 9876
1 8765
2 7654

Mathematical note: 1NF is primarily a condition on the representation of attribute values, not on functional dependencies or candidate keys. Atomicity is relative to the chosen data model and domains.

3. Second Normal Form (2NF)

A relation is in 2NF if:

  1. It is in 1NF.
  2. No non-prime attribute is partially functionally dependent on any candidate key.

A partial dependency occurs when a proper subset of a candidate key determines a non-prime attribute.

Formally, for every candidate key K, every proper subset X⊊K, and every non-prime attribute A:

X↛A

More precisely, the condition applies to dependencies implied by F+, the closure of the functional dependencies.

Example

Consider:

R(StudentID,CourseID,StudentName,Grade)

Functional dependencies:

StudentID→StudentName(StudentID,CourseID)→Grade

Assume the candidate key is:

K={StudentID,CourseID}

StudentName depends only on StudentID, a proper subset of the candidate key.

Therefore, the relation violates 2NF.

Decompose it into:

R1(StudentID,StudentName)R2(StudentID,CourseID,Grade)

The partial dependency is eliminated.

Important: If every candidate key consists of a single attribute, the relation automatically satisfies 2NF, provided it is in 1NF.

4. Third Normal Form (3NF)

A relation is in 3NF if, for every non-trivial functional dependency

X→A

at least one of the following holds:

  1. X is a superkey.
  2. A is a prime attribute.

A dependency is non-trivial when A∉X.

Equivalently:

X→A∈F+⟹X is a superkey∨A is prime

This is the formal definition of 3NF.

Example

Consider:

R(StudentID,DeptID,DeptName)

Dependencies:

StudentID→DeptIDDeptID→DeptName

Assume StudentID is the candidate key.

Then:

StudentID→DeptName

follows by transitivity.

However, DeptID is not a superkey, and DeptName is non-prime. Therefore, the dependency

DeptID→DeptName

violates 3NF.

Decompose into:

R1(StudentID,DeptID)R2(DeptID,DeptName)

Now department information is stored independently of individual students.

Why 3NF is stronger than 2NF: 2NF eliminates partial dependencies on candidate keys; 3NF also addresses problematic dependencies whose determinants are not superkeys, including transitive dependencies involving non-prime attributes.

5. Boyce–Codd Normal Form (BCNF)

A relation is in BCNF if, for every non-trivial functional dependency

X→Y

the determinant X is a superkey.

X→Y∈F+∧Y⊈X⟹X→R

Unlike 3NF, BCNF has no exception for prime attributes.

Example

Consider:

R(Student,Course,Instructor)

Suppose:

Dependencies:

(Student,Course)→InstructorInstructor→Course

Candidate keys are:

{Student,Course}

and

{Student,Instructor}

All three attributes are prime. Therefore, the relation satisfies 3NF.

However,

Instructor→Course

violates BCNF because Instructor is not a superkey.

Decompose into:

R1(Instructor,Course)R2(Student,Instructor)

Both resulting relations satisfy BCNF under the stated dependencies.

Key distinction: BCNF is stricter than 3NF. Every BCNF relation satisfies 3NF, but not every 3NF relation satisfies BCNF.

6. Fourth Normal Form (4NF)

BCNF deals with functional dependencies. 4NF also considers multivalued dependencies (MVDs).

An MVD

X↠Y

holds when, for a fixed value of X, the possible values of Y are independent of the remaining attributes Z=R−(X∪Y).

A relation is in 4NF if every non-trivial MVD

X↠Y

has X as a superkey.

X↠Y⟹X→R or the MVD is trivial

An MVD is trivial if Y⊆X or X∪Y=R.

Example

Suppose a student can have multiple independent hobbies and languages.

R(Student,Hobby,Language)

The dependencies are:

Student↠HobbyStudent↠Language

If hobbies and languages are independent, every hobby-language combination may need to be represented. This creates redundancy.

Decompose into:

R1(Student,Hobby)R2(Student,Language)

This eliminates the independent multivalued facts from being combined in one relation.

7. Fifth Normal Form (5NF)

5NF, also called Project-Join Normal Form (PJNF), addresses redundancy caused by join dependencies that cannot be explained solely by functional or multivalued dependencies.

A relation R satisfies 5NF if every non-trivial join dependency that holds on R is implied by its candidate keys.

Suppose:

R(S,P,J)

represents suppliers, parts, and projects. Under certain business rules, the relation may be reconstructed exactly from:

R1(S,P),R2(S,J),R3(P,J)

The corresponding join dependency is:

∗{SP,SJ,PJ}

meaning:

R=πSP(R)⋈πSJ(R)⋈πPJ(R)

when the dependency holds.

If this join dependency is non-trivial and is not implied by candidate keys, the relation violates 5NF and can be decomposed into those projections.

This decomposition is valid only if the business rules guarantee that joining the projections reconstructs exactly the original relation without spurious tuples.

Normal forms at a glance

Normal form Main mathematical condition
1NF Atomic attribute values
2NF No partial dependency of a non-prime attribute on a candidate key
3NF Every non-trivial FD has a superkey determinant or a prime RHS attribute
BCNF Every non-trivial FD has a superkey determinant
4NF Every non-trivial MVD has a superkey determinant
5NF Every non-trivial join dependency is implied by candidate keys

The central idea is that normalization decomposes relations to eliminate redundancy while preserving information. A good decomposition should ideally be lossless (joining the decomposed relations recovers the original relation) and, where possible, preserve the functional dependencies.