Latest Entries »

Wednesday, August 18, 2010

Database Normalization (1 to 3rd form)

In the relational database design, normalization is a systematic way of ensuring that a database structure is suitable for querying without insertion, update, and deletion anomalies that could lead to a loss of data integrity.

1st Normal Form
============
First you have to know what are the multivalued and composite attributes to understand the 1st normal form.

Multivalued Attribute is a attribute which can have more then a single value. For an example we can take a  person's telephone number. We can take many numbers as telephone number (Home tel number,Mobile number, tel number at office). To remove a multivalued attribute we have to divide the attribute.
Example: If we have attribute called "telephone", then we can divide it as "home telephone", "mobile number", "office number".

Composite attribute is a attribute which have several attributes. For an example the address attribute is can take as composite attribute. To remove this attribute we can divide the attribute to the sub attributes.
Example: If we have attribute called "address", then we can divide it to "no.", "street1", "street2", "city", "country".

These kind of attributes (multivalued and composite) should removed from the relation schema to get first normal form relation.

2nd Normal Form
=============
In the 2nd normal form it consider two dependencies called Functional dependencies and Partial dependencies. And also you should have the knowledge of primary key of a relational schema.

Functional dependency occurs when one attribute in a relation uniquely determines another attribute.

Partial dependency occurs when non-key attribute in a relation uniquely determines by sub set of primary key attribute set. Therefore to occur these kind of dependencies the primary key should contain more than one attributes.

All attributes in a relational schema should be fully functionally depend on the primary key of that relational schema. It means there should not occur any partial dependencies.

3rd Normal Form
=============
relational schema which have no transitive dependencies, called 3rd normal formed relational schema. transitive dependency occurs when a non-key attribute in a relational schema depends on another non-key attribute.