Normalization
The Evils of Redundancy
Functional Dependency
Let us understand functional dependency with example:
From the above , some valid functional dependencies are
empno → {ename, d_name, d_building}
empno → {dname}
d_name → {d_building}
Here are some invalid functional dependencies:
ename → {d_name}
d_building → {d_name}
Advantages
� Armstrong’s axioms�
Types of FDs
1. Trivial FD
{empno, ename} → ename
empno → empno
2. Non – trivial FD
empno → ename.
{empno, ename} → age
Types of FDs (cont.)
3. Transitive FD
empno → d_name and d_name → d_building then empno → d_building .
4. Multi – valued FD
empno → {ename, deptno}
is a multi - valued fd since the dependents ename and deptno are not dependent on each other.
Closure of an Attribute Set
─ Closure = X;
─ Repeat until there is no change
{
♦ If there is an FD U → V in F such that
U ⊆ closure
♦ Then set closure = closure U V
}
Example
F { A→B, B → C, C → D}.
Now, let us find the closure of some attributes and attribute sets-
Closure of attribute A-
A+ = { A }
= { A , B , C } ( Using A → B )
= { A , B , C } ( Using B → C )
= { A , B , C , D } ( Using C → D )
Thus,
A+ = { A , B , C , D }
Since A can determine all the attributes of the given relation therefore A is a candidate key.
Exercises
F { A → BC,
CD → E,
B → D,
E → A }
Compute CD+, E+.
2. Suppose, a relational schema R (A, B, C, D, E, F) and set of functional dependencies:
F { AB→C,
BC → AD,
D → E,
CF → B }
Compute BCF+, CD+,D+?
Normal forms
What is redundancy & Why should we reduce it?
Insertion anomaly
Deletion anomaly
Deletion anomaly
Updation Anomaly
Updation anomaly
Updation anomaly
Now the million dollar question is “How Normalization will solve all these problems?”
?
First Normal Form
Example
Second Normal Form
A relation is said to be in 2NF if and only if:
What is partial dependency?
Consider the following relation <student-course> to understand 2NF:
Pd: sid🡪sname, cid🡪cname
R1(sid, sname, cid), R2(cid, cname).
Third Normal form
The following dependencies exist:
Td: cid → grade
The table is in 1NF and in 2NF. But there is a transitive dependency between marks and grade, this violates the 3NF.
To get the third normal form (3NF), we have to put the grade in a separate table together with the clearing number to identify it.
BCNF (3.5 Normal Form)
Now the above tables are in BCNF.
Candidate key for <Package> table are Package and Ground
Candidate key for <TomorrowBookings> table are {Ground, Begin_Time} and {Ground, End_Time}
Fourth Normal Form