Unit 3 Normalization
Unit 3 Normalization
Partial Dependency
Partial Dependency exists, when for a composite primary
key, any attribute in the table depends only on a part of
the primary key and not on the complete primary key.
To remove Partial dependency, we can divide the table,
remove the attribute which is causing partial
dependency, and move it to some other table where it
fits in well.
Transitive Dependency
Consider attributes A, B, and C, and where
A → B and B → C.
Functional dependencies are transitive, which
means that we also have the functional
dependency
A→C
We say that C is transitively dependent on A
through B.
How to remove partial dependency
In example we should remove teacher
column from score table to remove partial
dependency.
Orwe can create new Teacher table and add
teachers information here.
Itshould be in the 2NF.
And it should not have Transitive Dependency
Scoretable in 2NF.
Now we also want to save columns
Exam_Name and Total_Marks in score table
Solution
BCNF is the advance version of 3NF. It is
stricter than 3NF.
A table is in BCNF if every functional
dependency X → Y, X is the super key of the
table.
it means, that for a dependency A → B, A
cannot be a non-prime attribute, if B is
a prime attribute.
For BCNF, the table should be in 3NF, and for
every FD, LHS is super key.
Example: Let's assume there is a company where employees
work in more than one department.
In the given table Functional dependencies are as follows:
EMP_ID → EMP_COUNTRY
EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
A table is said to be in the Fourth Normal
Form when,
It is in the Boyce-Codd Normal Form.
And, it doesn't have Multi-Valued
Dependency.
A relation is in 5NF if it is in 4NF and not
contains any join dependency and joining
should be lossless.
5NF is satisfied when all the tables are
broken into as many tables as possible in
order to avoid redundancy.
5NF is also known as Project-join normal
form (PJ/NF).
In the above table, John takes both Computer and Math class
for Semester 1 but he doesn't take Math class for Semester 2.
In this case, combination of all these fields required to identify
a valid data.
Suppose we add a new Semester as Semester 3 but do not
know about the subject and who will be taking that subject so
we leave Lecturer and Subject as NULL. But all three columns
together acts as a primary key, so we can't leave other two
columns blank.
So to make the above table into 5NF, we can decompose it into
three relations P1, P2 & P3:
Types of Join dependency
Lossless Join and
Dependency Preserving Decomposition
Decomposition of a relation is done when a
relation in relational model is not in
appropriate normal form.
Relation R is decomposed into two or more
relations if decomposition is lossless join as
well as dependency preserving.
If we decompose a relation R into relations R1 and R2,
Decomposition is lossy if R1 ⋈ R2 ⊃ R
Decomposition is lossless if R1 ⋈ R2 = R
To check for lossless join decomposition using FD set,
following conditions must hold:
Union of Attributes of R1 and R2 must be equal to
attribute of R.
Each attribute of R must be either in R1 or in R2.
Att(R1) U Att(R2) = Att(R)
Intersection of Attributes of R1 and R2 must not be
NULL.
Att(R1) ∩ Att(R2) ≠ Φ
Common attribute must be a key for at least one relation
(R1 or R2)
Att(R1) ∩ Att(R2) -> Att(R1) or Att(R1) ∩ Att(R2) -> Att(R2)
A relation R (A, B, C, D) with FD set{A->BC} is
decomposed into R1(ABC) and R2(AD) which
is a lossless join decomposition as:
First condition holds true as Att(R1) U Att(R2)
= (ABC) U (AD) = (ABCD) = Att(R).
Second condition holds true as Att(R1) ∩
Att(R2) = (ABC) ∩ (AD) ≠ Φ
Third condition holds true as Att(R1) ∩
Att(R2) = A is a key of R1(ABC) because A->BC
is given.
Ifwe decompose a relation R into relations
R1 and R2, All dependencies of R either must
be a part of R1 or R2 or must be derivable
from combination of FD’s of R1 and R2.