Normalisation: functional dependencies, BCNF and third normal form
Update, insertion and deletion anomalies, functional dependencies and Armstrong's axioms, closure and the key test, Heath's theorem proved, BCNF, 3NF and denormalisation.
A table that mixes information about different objects works until it has to be modified: then repeated data must be updated everywhere, and sooner or later someone forgets. Normalisation is the theory that says when a schema is well made and how to fix it. In this lesson we look at anomalies with an example, functional dependencies and Armstrong’s axioms, the closure of a set of attributes and the key test, Heath’s theorem with proof, Boyce-Codd normal form and third normal form.
Anomalies
Consider the table Exams(number, name, code, title, mark), which records exams with the student’s name and the course title. A student’s name appears in every one of their exams, a course’s title in every exam of that course. Three anomalies arise:
- update: to correct a course title hundreds of rows must be modified, and if one is skipped the data become inconsistent;
- insertion: a new course cannot be recorded until someone has taken its exam, because the key (number, code) requires a student number;
- deletion: deleting the last exam of a course also loses its title.
The cause is that the table represents three concepts (students, courses, exams) in one. The theory of functional dependencies makes this precise.
Functional dependencies
Given two sets of attributes
and
of a relation,
(
determines
) if two tuples equal on
are always equal on
too. In the example: number → name, code → title, (number, code) → mark. Functional dependencies are rules of the real world, like the cardinalities of the E-R model, and a key
is exactly a set of attributes such that
all attributes, minimally.
From some dependencies others are deduced with Armstrong’s axioms:
- reflexivity: if
, then
; - augmentation: if
, then
; - transitivity: if
and
, then
.
They are sound (they deduce only true dependencies) and complete (they deduce all those following from the initial ones).
Closure and the key test
The closure
of a set of attributes is the set of all attributes determined by
. It is computed starting from
and adding, while possible, the right-hand side of every dependency
whose left-hand side
is already contained in
.
is a superkey if and only if
contains all the attributes.
In the example,
: start from {number, code}, add name (from number), title (from code), mark (from the third dependency): all attributes, so it is a superkey, and since neither number nor code alone suffices, it is a key.
Decomposing without losing information
Normalising means decomposing a relation into smaller relations. But the decomposition must be lossless: putting the parts back together with the natural join must give exactly the original relation, with no spurious tuples.

Theorem (Heath). If a relation
satisfies
, then the decomposition into
and
is lossless:
.
Proof. *
.* Every tuple
of
has projection
in
and
in
, which combine again into
. *
.* Let
be a tuple of the join. It comes from
, projection of a tuple
of
, and from
, projection of a tuple
of
. The two tuples of
are equal on
, so by the dependency
they are equal on
:
. Then
belongs to
. ∎
Without the dependency the decomposition can create false tuples: if
corresponded to both
and
, the join would combine every
with every
of
, even those never seen together.
Normal forms
A relation is in Boyce-Codd normal form (BCNF) if, for every non-trivial dependency
,
is a superkey. In words: every fact the table records depends on the key, the whole key and nothing else. The Exams table is not in BCNF, because number → name and number is not a superkey. Applying Heath’s theorem twice gives Students(number, name), Courses(code, title) and Exams(number, code, mark): all in BCNF, and the anomalies disappear. It is the same schema that E-R design would have produced directly (lesson on the E-R model).
Decomposition into BCNF is always possible without loss, but sometimes it loses a dependency: it can no longer be checked within a single table. The typical case: in Lessons(student, subject, teacher), each teacher teaches a single subject (teacher → subject) and each student has a single teacher per subject ((student, subject) → teacher). Bringing it to BCNF separates (teacher, subject) from (student, teacher), and the rule linking student and subject to the teacher can no longer be checked in one table. Third normal form (3NF) is somewhat more permissive: it allows
even if
is not a superkey, provided
is part of a key. It can be proved that every schema can always be brought into 3NF losslessly while preserving all dependencies.
In practice one normalises up to 3NF or BCNF, and denormalises deliberately only where read speed is needed, as in data warehouses (lesson on distributed data), accepting redundancy in exchange for fewer joins.



