Normal
Normal
The main
purpose of normalization is to reduce redundant and duplicate data.
Redundant means unnecessary and repetitive means duplicate data. Please note redundant does not
mean repetitive but repetitive can be redundant.
There are three normalization techniques which are used heavily in relational world:-
For instance you can see the below table which has student names; if you ever want to query student
names having Koirala and not Harisingh, you can imagine what kind of a query you will end up with.
So the better approach would be to break this field into further logical pieces so that we can write clean
and optimal queries.
Second normal form says All keys should depend on the full primary key and not
partially.
In simple words data should depend fully on primary keys. For instance in the above table we can see the
primary key is created on roll number and standard. Now watch the syllabus field closely. The syllabus
field is associated with a standard and not with a student directly (roll number).
The syllabus is associated with the standard in which the student is studying and not directly with the
student. So if tomorrow we want to update the syllabus we have to update it for each student, which is
painstaking and not logical. It makes more sense to move these fields out and associate them with the
Standard table.
You can see how we have moved the syllabus field and attached it to the Standards table.This rule is
nothing but the 2nd normal form.
3rd normal form: No column should depend on other non-primary key columns.
In the above figure you can see how the average field is dependent on the marks and subject. This is also
one form of redundancy. So we can eliminate such calculative fields. This is third normal form.
What is Normalization? 1NF, 2NF, 3NF & BCNF
with Examples
What is Normalization?
Normalization is a database design technique which organizes tables in a manner that
reduces redundancy and dependency of data.
It divides larger tables to smaller tables and link them using relationships.
What is Normalization?
Database Normal Forms
1NF Rules
What is a KEY ?
What is Composite Key
2NF Rules
Database - Foreign Key
What is a transitive functional dependencies?
3NF Rules
Boyce-Codd Normal Form (BCNF)
The inventor of the relational model Edgar Codd proposed the theory of normalization
with the introduction of First Normal Form and he continued to extend theory with Second
and Third Normal Form. Later he joined with Raymond F. Boyce to develop the theory of
Boyce-Codd Normal Form.
Theory of Data Normalization in Sql is still being developed further. For example there are
discussions even on 6th Normal Form. But in most practical applications normalization
achieves its best in 3rd Normal Form. The evolution of Normalization theories is
illustrated below-
1NF Exmple
What is a KEY ?
A KEY is a value used to uniquely identify a record in a table. A KEY could be a single
column or combination of multiple columns
Note: Columns in a table that are NOT used to uniquely identify a record are called non-
key columns.
In our database , we have two people with the same name Robert Phil but they live at
different places.
Hence we require both Full Name and Address to uniquely identify a record. This is a
composite key.
We have divided our 1NF table into two tables viz. Table 1 and Table2. Table 1 contains
member information. Table 2 contains information on movies rented.
We have introduced a new column called Membership_id which is the primary key for
table 1. Records can be uniquely identified in Table 1 using membership id
You will only be able to insert values into your foreign key that exist in the unique key in
the parent table. This helps in referential integrity.
The above problem can be overcome by declaring membership id from Table2 as foreign
key of membership id from Table1
Now , if somebody tries to insert a value in the membership id field that does not exist in
the parent table , an error will be shown!
Consider the table 1. Changing the non-key column Full Name , may change Salutation.
3NF Example
We have again divided our tables and created a new table which stores Salutations.
There are no transitive functional dependencies and hence our table is in 3NF
Now our little example is in a level that cannot further be decomposed to attain higher
forms of normalization. In fact it is already in higher normalization forms. Separate efforts
for moving in to next levels of normalizing data are normally needed in complex
databases. However we will be discussing about next levels of normalizations in brief in
the following.
Summary
Database designing is critical to the successful implementation of a database
management system that meets the data requirements of an enterprise system.
Normalization helps produce database systems that are cost effective, cost
effective and have better security models.
Functional dependencies are a very important component of the normalize data
process
Most database systems are normalized database up to the third normal forms.
A primary uniquely identifies are record in a Table and cannot be null
A foreign key helps connect table and references a primary key