Normalization
Normalization
Normalization
Instructor :Farhan Sarwar
Topics To Cover
Normalization
It’s Purpose (to remove redundancy)
Anomalies related to Normalization
Normal Forms
Normalization
A technique of organizing data into multiple related tables, to minimize DATA REDUNDANCY and
to make the design meaningful.
Normalization works through a series of stages called normal forms:
First normal form (1NF)
Second normal form (2NF)
Third normal form (3NF)
BCNF
Fourth normal form (4NF)
Fifth normal form (5NF)
It’s Purpose
For a table to be in the Second Normal Form, it must satisfy two conditions:
The table should be in the First Normal Form.
There should be no Partial Dependency.
2nd Normal Form
What is Dependency?
Let's take an example of a Student table with columns student_id, name, reg_no(registration
number), branch and address(student's home address).
In this table, student_id is the primary key and will be unique for every row, hence we can use student_id to fetch
any row of data from this table
2nd Normal Form
Even for a case, where student names are same, if we know the student_id we can easily fetch the correct record.
Hence we can say a Primary Key for a table is the column or a group of columns(composite key) which can
uniquely identify each record in the table.
This is Dependency and we also call it Functional Dependency.
2nd Normal Form
So now let's extend our example to see if more than 1 column together can act as a primary key.
Let's create another table for Subject, which will have subject_id and subject_name fields and subject_id will be the
primary key.
2nd Normal Form
2nd Normal Form
2nd Normal Form
2nd Normal Form
2nd Normal Form
2nd Normal Form
3rd Normal Form
Transitive Dependency:
Primary key for our Score table is a composite key, which means it's made up of two attributes or columns → student_id
+ subject_id.
Our new column exam_name depends on both student and subject. For example, a mechanical engineering student will
have Workshop exam but a computer science student won't. And for some subjects you have Practical exams and for
some you don't. So we can say that exam_name is dependent on both student_id and subject_id.
But, the column total_marks depends on exam_name as with exam type the total score changes. For example, practicals
are of less marks while theory exams are of more marks.
But, exam_name is just another column in the score table. It is not a primary key or even a part of the primary key.
This is Transitive Dependency. When a non-prime attribute depends on other non-prime attributes.
3rd Normal Form
3rd Normal Form
3rd Normal Form
EXAMPLE TO SOLVE
Supplier Product Cost Markup Price Dept
Code
BCNF
4th Normal Form
5th Normal Form