NORMALIZATION OF DATABASE

The Need
• Illogically or inconsistently stored data can cause a number of problems. • In a relational database, a logical and efficient design is just as critical. • A poorly designed database may provide erroneous information, may be difficult to use, or may even fail to work properly.

Definition
• The process of designing a relational database includes making sure that a table contains only data directly related to the primary key, that each data field contains only one item of data, and that redundant (duplicated and unnecessary) data is eliminated. • The task of a database designer is to structure the data in a way that eliminates unnecessary duplication(s) and provides a rapid search path to all necessary information. • This process of specifying and defining tables, keys, columns, and relationships in order to create an efficient database is called normalization.

Normalization is part of successful database design. Without normalization, database systems can be inaccurate, slow, and inefficient and they might not produce the data you expect.

Un-Normal Form
• The database is said to be in an unnormal form if there are repeating group-of items in a data file.

Normal Forms
• We use the normalization process to design efficient and functional databases. By normalizing, we store data where it logically and uniquely belongs. The normalization process involves a few steps and each step is called a form.

I NF

2NF 3NF BCNF 4NF 5NF DKNF

Goals
• Arranging data into logical groups such that each group describes a small part of the whole • Minimizing the amount of duplicated data stored in a database • Building a database in which you can access and manipulate the data quickly and efficiently without compromising the integrity of the data storage • Organizing the data such that, when you modify it, you make the changes in only one place

Benefits
• Use storage space efficiently • Eliminate redundant data • Reduce or eliminate inconsistent data • Ease the database maintenance burden

1NF
• The relation is said to be in first normal form, if and only if all the fields in a record are single value. • There should not be any repeating groups of items

2NF
• A relation is said to be in second normal form if and only if it is in first normal form and every non key field completely depends on either the candidate keys (primary key/alternate key) or the concatenated key.

3NF
• A relation is said to be in third normal form, if no non key field depends on another non-key field. • This form further divides 2NF table into two more tables. So there are total 4 tables

4NF
• A relation is said to be in fourth normal form, if no key of a record type contains two or more data items which are independent and multi-valued • 4NF divides a 3NF table into 2 more tables. So there are 5 tables in all

SUPPLIER-ORDER TABLE (Un-normal form)
SUP. NO S01 SUP. NAME NCL CITY CODE 01 CITY NAME ND ITEM NO 101 ITEM NAME KBD QTY ORD 100 PRICE

110

S01

NCL

01

ND

102

MOUSE

100

50

S01

NCL

01

ND

103

PLUG

200

25

S02

EB

02

JAIPUR

103

PLUG

100

25

S03

KBD

02

JAIPUR

104

CPU

50

5000

SUPPLIER TABLE (1 N F)

SUP. NO S01

SUP. NAME NCL

CITY CODE 01

CITY NAME

ND

S02

EB

01

ND

S03

KBD

02

JAIPUR

ITEM-ORDER TABLE (1 N F)

SUP. NO S01 S01 S01 S02 S03

ITEM NO 101 102 103 103 104

ITEM NAME KBD MOUSE PLUG PLUG CPU

QTY ORD 100 100 200 100 50

PRICE 110 50 25 25 5000

SUPPLIER TABLE (2 N F)

SUP. NO S01

SUP. NAME NCL

CITY CODE 01

CITY NAME

ND

S02

EB

01

ND

S03

KBD

02

JAIPUR

ITEM TABLE (2 N F)

ITEM NO 101 102 103 103 104

ITEM NAME KBD MOUSE PLUG PLUG CPU

PRICE 110 50 25 25 5000

ORDER TABLE (2 N F)

SUP. NO S01 S01 S01 S02 S03

ITEM NO 101 102 103 103 104

QTY ORD 100 100 200 100 5000

SUPPLIER1 TABLE ( 3 N F )

SUP. NO S01

SUP. NAME NCL

CITY CODE 01

S02

EB

01

S03

KBD

02

CITY TABLE (3 N F )

CITY CODE 01

CITY NAME

ND

02

JAIPUR

SUPPLIER2 TABLE (4 N F )

SUP. NO S01

SUP. NAME NCL

S02

EB

S03

KBD

CITY1 TABLE (4 N F)

SUP. NO S01

CITY CODE 01

S02

01

S03

02