Friday, May 2, 2014

Database Normalization

Normalization is the way in which we organize the data of database to minimize redundancy(duplicate data). Normalization usually involves decomposing a large table into smaller tables and defining relationships between them(primary key and foreign key).

The main objective of normalization is to eliminate redundancy and undesired characteristics like creation,updation and deletion dependencies and ensuring data is logically stored.

First Normal Form(1NF): 

1)Table should consist of a primary key(uniquely identifies a row in the table)
2)Table shouldn't consists of duplicate data.
3)The values in a column should be of the same type.
4)The order of the rows should be insignificant.
5)Each column must be unique

Second Normal Form(2NF):

1)It should meet all the rules defined for 1NF and there shouldn't be no partial dependencies of any of the columns on the primary key.

To put the above point in another way, relations that have a single attribute for a key are automatically in 2NF.

E.g.: instead of having a primary key (customer_id, orders_id) for customer_orders table, we can divided the table into separate tables so  that each table has a separate primary key (customer_id) for customer table and (orders_id) for orders table.

Third Normal Form(3NF):

1)It should meet all the rules defined for 2NF and all the non primary fields should be dependent on primary key.

Thanks for visiting my blog!!!!!!!!!!