Normalization
Normalization
1. Functional dependency
2. Key
3. Entity set
4. Mapping Cardinalities
5. Extended E-R model
Functional Dependency
• It is a constraint between two sets of attributes in a
relation.
• If R is a relation, a FD denoted by X→Y between two
sets of attributes X and Y of R states that for any two
tupples t1 and t2 where t1[X]= t2[X] must have
t1[Y]= t2[Y]
• If X is a candidate key of R then X→Y for any subset
of attributes Y of R .
• If X→Y in R , it doesn’t infer Y→X.
Functional Dependency
• Fully Functional Dependency X→Y
If there is no Z where Z is a proper subset of X such
that Z→Y
• Partila Dependency
If K is a candidate key of a relation R and if X is a
proper subset of K and if X→Y then Y is said to be
partial dependent on K.
Functional Dependency
Name→ contactno, address
course→course_dept
Name,course→ grade
• Name,course is a candidate key
• Grade is fully functional dependent on the candidate key
• contactno is partial dependent on the candidate key
rollno→name,age,contactno
contactno → city
Here the transitive dependency is
rollno→contactno → city
Third normal form 3NF
• A relation schema is said to be in 3NF if it is in 2NF and
for all non-trivial FDs in F+ of the form X→Y, either X
contains a key or Y is a prime attribute.
• 3NF doesn’t permit partial or transitive dependency
• A database is in 3NF if every relation schema is in 3NF
empid ename desig deptno deptname
F= { empid→ename,desig,deptno,deptname
deptno → deptname }
There exist transitive dependency
empid→deptno → deptname
Third normal form 3NF
So to convert into 3NF, the above relation is
decomposed into
empid ename desig deptno
F1= { empid→ename,desig,deptno}
deptno deptname
F2={deptno → deptname }
3NF
rollno regnno course Grade
F= { rollno→name,dept
regnno→name,dept
rollno→regnno
regnno → rollno }
3NF to BCNF
time faculty subject roomno
F= { time,faculty→subject, roomno
subject→faculty }
Here {time,faculty} is the candidate key. So it is in 3NF but not
in BCNF.
So it is decomposed into two relations.
t1 James P Bob
t2 James Q Wills
t3 James P Wills
t4 James Q Bob
F1 ={ A→ B} F2 = {A→C}
A B C
1 2 3
R1 R2
F= {A→ B 2 2 3
B→ C,
A→ C} 3 2 3
4 3 4
Lossless join & Dependency Preserving
decomposition
Defn :A decomposition of a relation R (with functional
dependencies F) into relations R i (2<=i<=n) is said to be
Lossless if for every relation R i satisfies the FDs in F, the
natural join of Ri gives the original relation R. Otherwise the
decomposition is called Lossy.
A B C
CS white Navathe
CS black Korth
CS white Korth
R3 ←╥ B,C (R) A B C
D ef n : G i ve n a re l at i o n R w i t h a s et o f p ro j e c t i o n s
{ R 1 , R 2 , . . . . . R n } . T h e re l a t i o n R s a t i s f i e s t h e j o i n
dependencies *[R1,R2, .....Rn] if and only if the join of
projections Ri, 1<=i<n , is equal to R.
R = ╥ R1(R) * ╥ R2(R)* .......* ╥ Rn(R)