DB Week 10 Lec 1
DB Week 10 Lec 1
Normalization
WEEK 10 Lecture 1
Topics To Cover
Normalization
It’s Purpose (to remove redundancy)
Anomalies related to Normalization
Normal Forms
Normalization
Loss of a related
dataset when some
other dataset is
deleted.
Updation Anomaly
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.
his 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
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
EXAMPLE TO SOLVE
Supplier Product Cost Markup Price Dept
Code
BCNF
4th Normal Form
5th Normal Form