Normalization In Database
1NF, 2NF, 3NF
Normalization
• Normalization is the process of minimizing
redundancy from a relation or set of relations.
• Redundancy in relation may cause insertion,
deletion, and update anomalies.
• Normal forms are used to eliminate or reduce
redundancy in database tables.
Normalization And Normal Forms
• Decompose larger, complex table into simpler
and smaller ones
• Moves from lower normal forms to higher
normal form
• Usually done after E-R modeling
Normalization
Normal Forms
Second Higher Normal
First Normal Third Normal
Normal Form (BCNF,
Form (1NF) Form (3 NF)
Form (2NF) 4NF, 5NF, ...)
Need For Normalization
• In order to produce good database design, ask
questions:
– Does the design ensure all database operations will
be efficiently performed?
– Is there any expensive DBMS operations which
are avoidable?
– Is the information unnecessarily replicated?
Is it possible to insert a course
Can we delete the
which is not enrolled by any
course_details for a student
student? – Insertion
Tom? – Delete Anomalies
Anomalies
Student_Details Course_details Pre-requisite Result_details
0101 Tom M1 Physics-Math- Basic Math 02/11/2015 82 A
11/4/1985 Chemistry 7
0102 Rob M4 Physics-Bio- Basic Physics 21/11/2015 89 A
10/04/1986 Chemistry 8
0103 Mary B3 Botany-Zoology Basic Biology 12/11/2015 62 B
11/07/1985 10
0104 Rob H6 History-Geo-Eco Basic History 21/11/2015 89 A
10/04/1986 9
How many times the
How many rows should to be
student_details should be
updated if there is a change in
stored for each of the
student details for Rob? –
courses enrolled? – Data
Update Anomalies
Duplication
Normalization
Types of
Normal Form
First Normal
Form
(1NF)
Second Normal
Form
(2NF)
Third Normal
Form
(3NF)
Normalization
Types of
Normal Form
First Normal
Form Table Should not contain any
(1NF) multi-value Attribute
Second Normal
Form
(2NF)
Third Normal
Form
(3NF)
First Normal Form (1NF)
Student Marks Table
Student_Details Course_details Pre-requisite Result_details
0101 Tim 11/4/1985 M1 Physics-Math- Basic Math 02/11/2015 82 A
Chemistry 7
0102 Rob M4 Physics-Bio- Basic Physics 21/11/2015 89 A
10/04/1986 Chemistry 8
0103 Mary B3 Botany-Zoology 10 Basic Biology 12/11/2015 62 B
11/07/1985
First Normal Form (1NF)
Student Marks Table in 1NF
Studen Student Date Cours CourseN Pre- Durati Date Marks Grade
t# Name Of e# ame Requisit on in Of
Birth e days Exam
0101 Tim 11/4/ M1 Physics- Basic 7 02/11/ 82 A
1985 Math- Math 2015
Chemist
0102 Rob 10/04 M4 Physics- Basic 8 21/11/ 89 A
/1986 Bio- Physics 2015
Chemist
0103 Mary 11/07 B3 Botany- Basic 10 12/11/ 62 B
/1985 Zoology Biology 2015
Normalization
Types of
Normal Form
First Normal
Form
(1NF)
A relation is said to be in 2NF:
Second Normal
i) It is in 1NF.
Form ii) No partial dependency exists
(2NF) between non-key attributes and
key attributes.
Third Normal
Form
(3NF)
Second Normal Form (2NF)
• Key and Non Key Attributes of Student_marks table:
– Candidate key: {Student#, Course#}
– Key Attributes: Student#, Course#
– Non Key Attributes: StudentName, DOB,
CourseName, Pre-Requisite, DurationDays, Dateof
exam, Marks, Grade
• Functional dependencies:
– Student# ,Course# → Marks
– Student#, Course# → Grade
– Marks → Grade
Second Normal Form (2NF)
Student# → StudentName, DOB Partial
Course# → CourseName, Pre- Dependency
Requisite, DurationDays, with the Key
Dateof exam attribute
Split/Decompose the
tables
to remove partial
dependencies
Second Normal Form (2NF)
Student Marks Table in 1NF
Studen Student Date Cours CourseN Pre- Durati Date Marks Grade
t# Name Of e# ame Requisit on in Of
Birth e days Exam
0101 Tim 11/4/ M1 Physics- Basic 7 02/11/ 82 A
1985 Math- Math 2015
Chemist
0102 Rob 10/04 M4 Physics- Basic 8 21/11/ 89 A
/1986 Bio- Physics 2015
Chemist
0103 Mary 11/07 B3 Botany- Basic 10 12/11/ 62 B
/1985 Zoology Biology 2015
Second Normal Form (2NF)
Student# Student_N Date Of Birth Student# Course# Marks Grade
ame
0101 M1 82 A
0101 Tim 11/4/1985
0102 M3 89 A
0102 Rob 10/04/1986
0103 Mary 11/07/1985 0103 B3 62 B
Course# CourseName Prerequisite Durationindays Date Of
Exam
M1 Physics-Math- Basic Math 7 02/11/2015
Chemistry
M3 Physics-Bio- Basic Physics 8 21/11/2015
Chemistry
B3 Botany-Zoology Basic Biology 10 12/11/2015
Normalization
Types of
Normal Form
First Normal
Form
(1NF)
A relation is said to be in 3NF:
Second Normal i) It is in 2NF.
Form
(2NF) ii) No transitive dependency
exists between non-key
Third Normal attributes and key attributes
Form through another non-key
(3NF)
attribute.
Third Normal Form (3NF)
Student# Course# Marks Grade
0101 M1 82 A
0102 M3 89 A
0103 B3 62 B
• Student# ,Course# → Marks
• Student#, Course# → Grade
• Marks → Grade
Student#, Course#→ Marks→ Grade: TD Remove
Third Normal Form (3NF)
Result Table Marks Grade Table
Student# Course# Marks Marks Grade
0101 M1 82 82 A
0102 M3 89 89 A
0103 B3 62 62 B
Pros And Cons Of Normalization
➢ Based on mathematical ➢ Data retrieval or SELECT
foundation operation performance will be
➢ Removes the redundancy to a severely affected
large extent ➢ Normalization might not
➢ After 3NF, data redundancy is always
minimized to the extent of foreign represent real world scenarios
keys
➢ Removes the anomalies present
in INSERTs, UPDATEs and
DELETEs