Normal Forms
Normal Forms
As there are multiple values of phone number for sid 1 and 3, the above table is
not in 1NF. We can make it in 1NF. The conversion is as follows -
Second Normal Form
Before understanding the second normal form let us first discuss the concept of j
functional dependency and prime and non-prime attributes.
Concept of Partial Functional Dependency
Partial dependency means that a nonprime attribute is functionally dependent on
part of a candidate key.
For example: Consider a relation R(A,B,C,D) with functional dependency {AB-
>CD,A->C}
Here (AB) is a candidate key because
(AB)+ = {ABCD} = {R}
Hence {A,B) are prime attributes and {C,D) are non prime attribute. In A->C, the
non prime attribute C is dependent upon A which is actually a part of candidate
key AB. Hence due to A->C we get partial functional dependency.
Prime and Non Prime Attributes
• Prime attribute: An attribute, which is a part of the candidate-key, is known as
a prime attribute.
• Non-prime attribute: An attribute, which is not a part of the prime-key, is said
to be a non-prime attribute.
• Example : Consider a Relation R ={A,B,C,D) and candidate key as AB, the
Prime attributes: A, B
Non Prime attributes: C, D
The Second Normal Form
For a table to be in the Second Normal Form, following conditions must be
followed
i) It should be in the First Normal form.
ii) It should not have partial functional dependency.
For example: Consider following table in which every information about a the
Student is maintained in a table such as student id(sid), student name(sname),
course id(cid) and course name(cname).
Student_Course
This table is not in 2NF. For converting above table to 2NF we must follow the
following steps -
Step 1: The above table is in 1NF.
Step 2: Here sname and sid are associated similarly cid and cname are associated
with each other. Now if we delete a record with sid=2, then automatically the
course C++ will also get deleted. Thus,
sid->sname or cid->cname is a partial functional dependency, because {sid,cid}
should be essentially a candidate key for above table. Hence to bring the above
table to 2NF we must decompose it as follows:
Student:
Course:
Superkeys
• {RegID}
• {RegID, RollNo}
• {RegID,Sname}
• {RollNo,Sname}
• {RegID, RollNo,Sname}
Candidate Keys
• {RegID}
• {RollNo}
Third Normal Form
A table is said to be in the Third Normal Form when,
i) It is in the Second Normal form.(i.e. it does not have partial functional
dependency)
ii) It doesn't have transitive dependency.
Or in other words
In other words 3NF can be defined as: A table is in 3NF if it is in 2NF and for
each functional dependency
X-> Y
at least one of the following conditions hold :
i) X is a super key of table
ii) Y is a prime attribute of table
For example: Consider following table Student_details as follows -
Here
Super keys: {sid}, {sid,sname}, {sid,sname,zipcode}, {sid,zipcode,cityname}...
and so on.
Candidate keys:{sid}
Non-Prime attributes: {sname,zipcode,cityname,state}
The dependencies can be denoted as,
sid->sname
sid->zipcode
zipcode->cityname
cityname->state
The above denotes the transitive dependency. Hence above table is not in 3NF.
We can convert it into 3NF as follows:
Student
Zip
Example 2.11.1 Consider the relation R = {A, B, C, D, E, F, G, H, I, J} and the
set of functional dependencies F= {{A, B} →C, A →{D, E}, B→F, F→ {G, H},
D →{I, J} }
1. What is the key for R? Demonstrate it using the inference rules.
2. Decompose R into 2NF, then 3NF relations.
Solution: Let,
A→ DE (given)
A→ D, A→ E
AsD→IJ, A→IJ
Using union rule we get
A → DEIJ
As A→ A
we get A → ADEIJ
Using augmentation rule we compute AB
AB → ABDEIJ
But
AB→C (given)
AB →ABCDEIJ
B→ F (given) F→ GH .. B→ GH (transitivity)
AB →AGH is also true
Similarly AB→ AF B→F (given)
Thus now using union rule
AB → ABCDEFGHIJ
AB is a key
The table can be converted to 2NF as,
R1= (A, B, C)
R2= (A, D, E, I, J) smoot
R3= (B, F, G, H)
The above 2NF relations can be converted to 3NF as follows:
R1= (A, B, C)
R2= (A, D, E)
R1= (D, I, J)
R1= (B, E)
R3= (E, G, H).
Review Questions
1. What is database normalization? Explain the first normal form, second normal
form and third normal form.AU: May-18, Marks 13; Dec.-15, Marks 16
2. What are normal forms. Explain the types of normal form with an
example. AU: Dec.-14, Marks 16
3. What is normalization? Explain in detail about all Normal forms. AU:
May-19, Marks 13
4. Briefly discuss about the functional dependency concepts. AU: May-
19, Marks 13
Boyce / Codd Normal Form (BCNF)
Boyce and Codd Normal Form is a higher version of the Third Normal form. This
form deals with certain type of anomaly that is not handled by 3NF.
A 3NF table which does not have multiple overlapping candidate keys is said to
be in BCNF.
Or in other words,
For a table to be in BCNF, following conditions must be satisfied:
i) R must be in 3rd Normal Form
ii) For each functional dependency (X → Y), X should be a super Key. In simple
words if Y is a prime attribute then X can not be non prime attribute.
For example - Consider following table that represents that a Student enrollment
for the course -
Enrollment Table
From above table following observations can be made:
• One student can enroll for multiple courses. For example student with sid=1 can
enroll for C as well as Java.
• For each course, a teacher is assigned to the student.
• There can be multiple teachers teaching one course for example course C can
be taught by both the teachers namely - Ankita and Archana.
• The candidate key for above table can be (sid,course), because using these two
columns we can find
• The above table holds following dependencies,
• (sid,course)->Teacher
• Teacher->courseann
• The above table is not in BCNF because of the dependency teacher->course.
Note NS that the teacher is not a superkey or in other words, teacher is a non
prime attribute and course is a prime attribute and non-prime attribute derives the
prime attribute.
• To convert the above table to BCNF we must decompose above table into
Student and Course tables
Student
Course
Now the table is in BCNF
Example 2.12.1 Consider a relation(A,B,C,D) having following FDs.(AB->C,
AB->D, C->A, B->D). Find out the normal form of R.
Solution:
Step 1: We will first find out the candidate key from the given FD.
(AB)+= {ABCD) = R
(BC)+={ABCD) = R
(AC)+ ={AC} R
There is no involvement of D on LHS of the FD rules. Hence D can not be part
of any candidate key. Thus we obtain two candidate keys (AB)* and (BC)*.
Hence
prime attributes = {A,B,C)
Non prime attributes = {D}
Step 2: Now, we will start checking from reverse manner, that means from
BCNF, so then 3NF, then 2NF.
Step 3: For R being in BCNF for X->Y the X should be candidate key or super
key. From above FDs consider C->D in which C is not a candidate key or super
key. Inabu Hence given relation is not in BCNF.
Step 4: For R being in 3NF for X->Y either i) the X should be candidate key or
super key or ii) Y should be prime attribute. (For prime and non prime attributes
refer step 1)
• For AB->C or AB->D the AB is a candidate key. Condition for 3NF is
satisfied.
• Consider C->A. In this FD the C is not candidate key but A is a prime attribute.
Condition for 3NF is satisfied.
• Now consider B->D. In this FD, the B is not candidate key, similarly D is not
a prime attribute. Hence condition for 3NF fails over here.
Hence given relation is not in 3NF.
Step 5: For R being in 2NF following condition should not occur.
Let X->Y, if X is a proper subset of candidate key and Y is a non prime attribute.
This is a case of partial functional dependency.
For relation to be in 2NF there should not be any partial functional dependency.
• For AB->C or AB->D the AB is a complete candidate key. Condition for 2NF
is satisfied.
• Consider C->A. In this FD the C is not candidate key. Condition for 2NF is
satisfied.
• Now consider B->D. In this FD, the B is a part of candidate key(AB or BC),
similarly D is not a prime attribute. That means partial functional dependency
occurs here. Hence condition for 2NF fails over here.
Hence given relation is not in 2NF.
Therefore we can conclude that the given relation R is in 1NF.
Example 2.12.2 Consider a relation R(ABC) with following FD A->B, B->C and
C->A. What is the normal form of R?
Solution:
Step 1: We will find the candidate key
(A)+ ={ABC} =R
(B)+ = {ABC} =R
(C)+={ABC} =R
Hence A, B and C all are candidate keys
Prime attributes = {A,B,C}
Non prime attribute {}
Step 2:For R being in BCNF for X->Y the X should be candidate key or super
key. From above FDs
• Consider A->B in which A is a candidate key or super key. Condition for
BCNF is satisfied.
• Consider B->C in which B is a candidate key or super key. Condition for
BCNF is satisfied.
• Consider C->A in which C is a candidate key or super key. Condition forBCNF
is satisfied.
This shows that the given relation R is in BCNF.
Example 2.12.3 Prove that any relational schema with two attributes is in BCNF.
Solution: Here, we will consider R={A,B) i.e. a relational schema with two
attributes. Now various possible FDs are A->B, B->A.
From the above FDs
• Consider A->B in which A is a candidate key or super key. Condition for
BCNF is satisfied.
• Consider B->A in which B is a candidate key or super key. Condition for
BCNF is satisfied.
• Consider both A->B and B->A with both A and B is candidate key or super
key. Condition for BCNF is satisfied.
• No FD holds in relation R. In this {A,B) is candidate key or super key. Still
condition for BCNF is satisfied.
This shows that any relation R is in BCNF with two attributes.
Multivalued Dependencies and Fourth Normal Form
AU: May-14, Dec.-16, 19, Marks 16
Concept of Multivalued Dependencies
• A table is said to have multi-valued dependency, if the following conditions are
true,
1) For a dependency A→B, if for a single value of A, multiple values of B exists,
then the table may have multi-values dependency.
2) Also, a table should have at-least 3 columns for it to have a multi-valued
dependency.
3) And, for a relation R(A,B,C), if there is a multi-valued dependency between,
A and B, then B and C should be independent of each other.
If all these conditions are true for any relation(table), it is said to have multi-
valued dependency.
• In simple terms, if there are two columns A and B - and for column A if there
are multiple values of column B then we say that MVD exists between A and B
• The multivalued dependency is denoted by →
• If there exists a multivalued dependency then the table is not in 4th normal
form.
• For example: Consider following table for information about student
Student
Here sid =1 leads to multiple values for courses and skill. Following table shows
this
Here sid and course are dependent but the Course and Skill are independent.
The multivalued dependency is denoted as :
sid→ Course
sid→ Skill
Fourth Normal Form
Definition: For a table to satisfy the Fourth Normal Form, it should satisfy the
following two conditions:
1) It should be in the Boyce-Codd Normal Form(BCNF).
2) And, the table should not have any multi-valued dependency.
For example: Consider following student relation which is not in 4NF as it
contains multivalued dependency.
Student Table
Now to convert the above table to 4NF we must decompose the table into
following two tables.
Student_Course Table
Key: (sid,Course)
Student Skill Table
Key: (sid, Skill)
Review Questions
1. Explain first normal form, second normal form, third normal form and BCNF
with example. AU: Dec.-16, Marks 13
2. Explain Boyce Codd normal form and fourth normal form with suitable
example. AU: May-14, Marks 16
3. Exemplify the multi-value dependency and fourth normal form 4NF. AU:
Dec.-19, Marks 6
Join Dependencies and Fifth Normal Form
Concept of Join Dependencies
• Join decomposition is a further generalization of Multivalued dependencies.
• If the join of R1 and R2 over C is equal to relation R, then we can say that a
Join Dependency (JD) exists.
• Where R1 and R2 are the decompositions R1(A, B, C) and R2(C, D) of a given
relations R (A, B, C, D).
• Alternatively, R1 and R2 are a lossless decomposition of R.
• A JD (R1, R2,..., Rn} is said to hold over a relation R if R1, R2,....., Rn is a
lossless-join decomposition.
• The *(A, B, C, D), (C, D) will be a JD of R if the join of join's attribute is equal
to the relation R.
• Here, *(R1, R2, R3) is used to indicate that relation R1, R2, R3 and so on are a
JD of R.
Concept of Fifth Normal Form
The database is said to be in 5NF if -
i) It is in 4th Normal Form
ii) If we can decompose table further to eliminate redundancy and anomalies and
when we rejoin the table we should not be losing the original data or get a new
record (join Dependency Principle)
The fifth normal form is also called as project join normal form
For example - Consider following table
The above table is in 4th Normal Form as there is no multivalued dependency. But
it is not in 5th normal form because if we join the above two table we may get
To avoid the above problem we can decompose the tables into three tables as
Seller_Company, Seller_Product, and Company Product table