Lecture 8 - Normalisation
Lecture 8 - Normalisation
Outline
• Definition
• Update, insertion, and deletion Anomalies
Normalised Databases • Functional Dependencies
• Normalization Process
– First normal form(1NF)
– 2NF
Some of the slides are adopted from – 3NF
Ramakrishnan and Gehrke 2003
– BCNF, etc.
Normalization Normalization
• Normalization is a technique for producing a set • Suitable set of relations will be:
of suitable relations that support the data – easier for the user to access and maintain the
requirements of an enterprise. data;
• Relations should have: – take up minimal storage space on the computer.
– minimal number of attributes necessary to support • Normalization tries to minimize data
the data requirements of the enterprise;
redundancies
– attributes with a close logical relationship in the same
relation; • Redundancy is at the root of several problems
– minimal redundancy with each attribute represented associated with relational schemas:
only once with the important exception of attributes – redundant storage, insert/ delete/ update
that form all or part of foreign keys. anomalies
3 4
5 6
1
4/1/2015
7 8
Anomalies Normalization...
• Insertion • Two important properties of decomposition.
– If we add a new copy of “Sooty” we must make – Lossless-join property enables us to find any
sure the details are consistent instance of the original relation from
• Update corresponding instances in the smaller relations.
– Change length of Sooty must be performed – Dependency preservation property enables us to
consistently on each copy enforce a constraint on the original relation by
• Delete enforcing some constraint on each of the smaller
– Deleting the last copy throws out the information relations.
on “Sooty”
9 10
Functional Dependencies
• Functional dependency describes relationship Functional Dependencies ctd.
between attributes.
– For example, if A and B are attributes of relation R, • Example:
B is functionally dependent on A (denoted AB), The following functional dependencies
if each value of A in R is associated with exactly appear to hold.
one value of B in R. – staffNo sName
• The determinant of a functional dependency – sName staffNo - may not hold all the time
refers to the attribute or group of attributes
on the left-hand side of the arrow, B is called
the dependent.
• The functional dependency is said to be trivial
if Y is a subset of X. 11 12
2
4/1/2015
13 14
3
4/1/2015
19 20
Name Children
Noah {Shem, Ham, Japeth} The problem is functional
dependency
Isaac {Jacob, Esau}
Noah Shem
Normalised
Table Noah Ham Identify functional dependency
And redesign tables
Noah Japeth
Isaac Jacob
Isaac Esau
21 22
23 24
4
4/1/2015
StudentID Course Title Mark Instructor StudentID Course Title Mark Instructor
27 28
5
4/1/2015
33 34
35 36
6
4/1/2015
37 38
Remarks Summary
• BCNF is stronger than 3NF • Relations with data redundancy suffer from
• Fourth NF removes multi valued dependency update anomalies
• Functional dependency identified as the cause
• Fifth NF concerns lossless join dependency of the problem
• We will not cover 4NF, 5NF • Normalisation (2NF, 3NF, BCNF) characterises
various kinds of functional dependency
• Decompose into smaller tables removing the
functional dependency
39 40