Review - Normal Forms2
Review - Normal Forms2
Normal Forms
DR. RICHA SHARMA
L O C K H AV E N U N I V E R S I T Y
1
Introduction
Process for correcting the table structures to minimize
data redundancies and hence, reduce data anomalies!
We progressively break table into new set of relations
based on identified functional dependencies!
Example:
name, address attribute should be separated into distinct
columns.
multiple data values separated by comma are there on
any attribute, say a list of employees on a project – add
rows for such repeating groups.
4
Functional Dependency
An attribute B is said to be fully functionally dependent on the
attribute A if each value of A determines one and only one
value of B.
Example: Employee Id (determinant attribute) determines
Employee name (dependent attribute)
Attribute A determines attribute B if all of the rows in the table
that agree in value for attribute A also agree in value for
attribute B.
What if A is a composite key? - If attribute B is functionally
dependent on a composite key A but not on any subset of that
composite key, the attribute B is fully functionally dependent
on A.
5
Functional Dependency
Partial Dependency – exists when there is a functional
dependence in which the determinant is only part of the
primary key.
Example: if (A, B) (C, D), B C, and (A, B) is the primary
key, then the functional dependence B C is a partial
dependency!
Transitive Dependency – exists when there are functional
dependencies such that X Y, Y Z, and X is the primary key,
then the dependency X Z is a transitive dependency
because X determines the value of Z via Y.
6
Second Normal Form
Eliminates redundant data by requiring that each non-key
attribute should be dependent on the primary key.
7
Third Normal Form
3NF builds on 2NF by requiring that all non-key attributes are
independent of each other.
A table is in 3NF if it is in 2NF and contains no transitive
dependencies.
Is this table in 1NF, 2NF, 3NF?
Student Id Course Code Name City Course Name Semester Year Grade
8
Third Normal Form
Is this table in 1NF, 2NF, 3NF?
9
BCNF
BCNF is a stricter form of 3NF that ensures that each
determinant in a table is a candidate key.
BCNF ensures that each non-key attribute is dependent
only on the candidate key!
(A, C, D)
(C, B)
Both of these relations are in 3NF as well as BCNF!
12
Fourth Normal Form
4NF is a further refinement of BCNF that ensures that a table
does not contain any multi-valued dependencies.
For a table to satisfy the 4NF, it should satisfy the following
two conditions:
It should be in BCNF.
The table should not have any Multi-valued
Dependency.
13
Fifth Normal Form
5NF is the highest level of normalization, also known as
Project-join NF (PJ/NF).
It involves decomposing a table into smaller tables to remove
data redundancy, improve data integrity and ensure lossless
join property (no join dependency)
Lossless join property - ensures that no spurious or extra
tuples are generated when relations are reunited through a
natural join.
14
Closure of a set of attributes
Closure of an Attribute: it is a set of attributes that can be
functionally determined from it using the given functional
dependencies and the inference rules from FDs [closure of
FDs].
{F}+ = { A → B, B → CD, A → CD }
(A)+ = ABCD
15
Closure to find candidate keys
Given relational schema R(X, Y, Z, W) and FD= { XYZ → W, XY
→ ZW and X → YZW }. Let’s work out the candidate keys for R.
(XYZ)+ = XYZW
(XY) + = XYZW
(X) + = XYZW
Since antecedent of each FD is determining all the attributes of
the table, therefore each of these is a superkey.
Candidate key is the minimal superkey, therefore X is the
candidate key here!
16
Closure - exercise
Given relational schema R( P, Q, R, S, T, U, V) having set of
functional dependencies. Let’s find (QR)+ and (PR)+
17