Normalization 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Normalization

o Normalization is the process of organizing the data in the database.


o Normalization is used to minimize the redundancy from a relation or set of relations. It
is also used to eliminate the undesirable characteristics like Insertion, Update and
Deletion Anomalies.
o Normalization divides the larger table into the smaller table and links them using
relationship.
o The normal form is used to reduce redundancy from the database table.

First Normal Form (1NF)


o A relation will be 1NF if it contains only atomic values.

o It states that an attribute of a table cannot hold multiple values. It must hold only single-
valued attribute.

o First normal form disallows the multi-valued attribute, composite attribute, and their
combinations.

Example: Relation EMPLOYEE is not in 1NF because of multi-valued attribute EMP_PHONE.

EMPLOYEE table:

EMP_ID EMP_NAME EMP_PHONE EMP_STATE

14 John 7272826385, UP
9064738238

20 Harry 8574783832 Bihar

12 Sam 7390372389, Punjab


8589830302

The decomposition of the EMPLOYEE table into 1NF has been shown below:

EMP_ID EMP_NAME EMP_PHONE EMP_STATE

14 John 7272826385 UP
14 John 9064738238 UP

20 Harry 8574783832 Bihar

12 Sam 7390372389 Punjab

12 Sam 8589830302 Punjab

Second Normal Form (2NF)

A database is in second normal form if it satisfies the following conditions:

1)It is in first normal form

2)All non-key attributes are fully functional dependent on the primary key, ie., it has no partial
dependencies on the primary key

Partial Dependency

Partial Dependency occurs when a non-prime attribute is functionally dependent on part of a


candidate key

TABLE_Purchase_details

Cust_ID Store_ID Purchase_location

1 1 Delhi

1 3 Chennai
2 1 Delhi
3 2 Kolkata
4 4 Delhi
This table has a composite primary key [Cust_ID, Store _ID]. The non-key attribute
[Purchase Location] only depends on [Store ID], which is only part of the primary key,
ie., it has partial dependency. As per the Second Normal Form there must not be any
partial dependency of any column on primary key.

Therefore, this table does not satisfy second normal form.

To bring this table to second normal form, we break the table into two tables, and
now we have the following:

Table_purchase

Cust_ID Store_ID
1 1
1 3
2 1
3 2
4 3

Table_store

Store_ID Purchase_location
1 Delhi
2 Kolkata
3 Chennai

4 Delhi

In the table [TABLE_STORE],the column [Purchase_Location] is fully dependent on the primary


key of that table,which is [Store_ID].
Third Normal Form (3NF):
A relation is in third normal form, if there is no transitive dependency for non-
prime attributes as well as it is in second normal form.

 Table must be in 2NF


 Transitive functional dependency of non-prime attribute on any super key
should be removed.

An attribute that is not part of any candidate key is known as non-prime attribute.

In other words 3NF can be explained like this: A table is in 3NF if it is in 2NF and
for each functional dependency X-> Y at least one of the following conditions
hold:

 X is a super key of table


 Y is a prime attribute of table

Note – If A->B and B->C are two FDs then A->C is called transitive
dependency.
.

Example-1:
STUDENT
STUD_NO STUD_NAME STUD_STATE STUD_COUNTRY STUD_AGE
1 RAM HARYANA INDIA 20
2 RAM PUNJAB INDIA 19
3 SURESH PUNJAB INDIA 21
4 ANIL UP INDIA 20

FD set:
{STUD_NO -> STUD_NAME, STUD_NO -> STUD_STATE, STUD_STATE ->
STUD_COUNTRY, STUD_NO -> STUD_AGE}
Candidate Key:
{STUD_NO}
For this relation , STUD_NO -> STUD_STATE and STUD_STATE ->
STUD_COUNTRY are true. So STUD_COUNTRY is transitively dependent on
STUD_NO. It violates the third normal form. To convert it in third normal form,
we will decompose the relation STUDENT (STUD_NO, STUD_NAME,
STUD_PHONE, STUD_STATE, STUD_COUNTRY_STUD_AGE) as:
STUDENT (STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE, STUD_AGE)
STATE_COUNTRY (STATE, COUNTRY)

You might also like