Introduction of Database Normalization
Introduction of Database Normalization
Functional Dependency:
Functional Dependency is a constraint between two
sets of attributes in relation to a database. A
functional dependency is denoted by an arrow (→).
If an attribute A functionally determines B, then it is
written as A → B.
For example, employee_id → name means
employee_id functionally determines the name of
the employee. As another example in a timetable
database, {student_id, time} → {lecture_room},
student ID and time determine the lecture room
where the student should be.
What does functionally dependent mean?
A function dependency A → B means for all
instances of a particular value of A, there is the
same value of B.
2
A B
------
1 3
2 3
4 0
1 3
4 0
Trivial Functional Dependency:
X → Y is trivial only when Y is subset of X.
Examples
ABC → AB
ABC → A
ABC → ABC
Non Trivial Functional Dependencies:
X → Y is a non trivial functional dependency when
Y is not a subset of X.
X → Y is called completely non-trivial when X
intersect Y is NULL.
3
Example:
Id → Name,
Name → DOB
Example:
Roll_no name dept_name dept_building
42 abc CO A4
43 pqr IT A3
44 xyz CO A4
4
45 xyz IT A3
46 mno EC B2
47 jkl ME B2
42 abc 17
43 pqr 18
44 xyz 18
7
42 abc 17
43 pqr 18
44 xyz 18
For example,
roll_n
o name age
42 abc 17
43 pqr 18
44 xyz 18
45 abc 19
Here, roll_no → {name, age} is a multivalued
functional dependency, since the
dependents name & age are not dependent on
each other(i.e. name → age or age → name
doesn’t exist !)
9
42 abc CO 4
43 pqr EC 2
44 xyz IT 1
45 abc EC 2
Here, enrol_no → dept and dept → building_no,
Hence, according to the axiom of
transitivity, enrol_no → building_no is a valid
functional dependency. This is an indirect functional
dependency, hence called Transitive functional
dependency.
STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE
hold
but
STUD_NAME->STUD_STATE do not hold
{ STUD_NO->STUD_NAME, STUD_NO-
>STUD_PHONE, STUD_NO->STUD_STATE, STUD_NO-
>STUD_COUNTRY,
STUD_NO -> STUD_AGE, STUD_STATE-
>STUD_COUNTRY }
Attribute Closure: Attribute closure of an attribute
set can be defined as set of attributes which can be
functionally determined from it.
How to find attribute closure of an attribute set?
To find attribute closure of an attribute set:
Add elements of attribute set to the result set.
12
Example 2 –
17
ID Name Courses
------------------
1 A c1, c2
2 E c3
3 M C2, c3
In the above table Course is a multi-valued
attribute so it is not in 1NF.
Below Table is in 1NF as there is no multi-valued
attribute
ID Name Course
------------------
1 A c1
1 A c2
2 E c3
3 M c2
3 M c3
STUD_NO COURSE_NO
COURSE_NO
COURSE_FEE
1 C1 C1
1000
2 C2 C2
1500
1 C4 C3
1000
4 C3 C4
2000
4 C1 C5
2000
2 C5
NOTE: 2NF tries to reduce the redundant data
getting stored in memory. For instance, if there are
100 students taking C1 course, we don’t need to
store its Fee as 1000 for all the 100 records,
instead, once we can store it in the second table as
the course fee for C1 is 1000.
satisfied.
If all attributes of relation are prime attribute,