normalization in a database

9

Upload: bishrul-haq

Post on 12-Aug-2015

58 views

Category:

Education


1 download

TRANSCRIPT

What is Normalization? It’s a process of minimizing DATA redundancy. The main objectivity is to divide the table as an user friendly way to update, edit and delete any data without accessing each table. At the end we’ll be able to Insert, delete, update data without any problems.

INSERT ANOMALY: This refers to the situation when it is impossible to insert certain types of data into the database.

DELETE ANOMALY: The deletion of data leads to unintended loss of additional data, data that we had wished to preserve.

UPDATE ANOMALY : This refers to the situation where updating the value of a column leads to database inconsistencies (i.e., different rows on the table have different values).

Different levels of Database Normalization

1st Normal Form (1NF)

2nd Normal Form (2NF)

3rd Normal Form (3NF)

Note There are 5 Normalization Forms, We are only focusing 3 of them.

1st Normal Form (1NF)

The Database in First Normal form should completed the below conditions.• Contains only non dividable values (Atomic Values).• No Replica (Cannot contain Duplication).• It Should be in un-normalized Form.

Item ID Item Cost (Rs.)

A001 Rata Kaju, Idiyappa 70

A002 Lemonade 30

A003 Spaghetti 150

A004 Lemonade 40

A005 Kottu 160

Item ID Cost (Rs.)

A001 70

A002 30

A003 150

A004 40

A005 160

Item ID Item

A001 Rata Kaju

A001 Idiyappa

A002 Lemonade

A003 Spaghetti

A004 Lemonade

A004 Kottu

Product Table

Product Price Table Item Table

2nd Normal Form (2NF)

The Database in Second Normal form should completed the below conditions.• It Should be in 1st Normal Form.

• All Non-Keys should be dependent to the Primary Key.

NoteNon-key attributes are attributes other than candidate key attributes in a table.

Purchase ID Bar Code ID Store Location

A001 Bar001 Left Store

A002 Bar002 Underground Store

A001 Bar001 Left Store

A004 Bar003 Main Store

A004 Bar002 Underground Store

Purchase ID Bar Code ID

A001 Bar001

A002 Bar002

A001 Bar001

A004 Bar003

A004 Bar002

Bar Code ID Store Location

Bar001 Left Store

Bar002 Underground Store

Bar003 Main Store

Composite Key Purchase Table

Purchase Bar Code Table Item Location Table

3rd Normal Form (3NF)

The Database in Third Normal form should completed the below conditions.• It Should be in 2st Normal Form.• There is no transitive functional dependency.

Class ID Course ID Course Name

Re001 0037 Computer Science Yamanato

Re002 0045 Cookery Jhon

Re001 0037 Computer Science Khan

Re002 0045 Cookery Elina

Re005 0016 Fashion Designing Suman

Class ID Course ID Name

A001 0037 Yamanato

A002 0045 Jhon

A003 0037 Khan

A004 0045 Elina

A005 0016 Suman

Course ID Course

0037 Computer Science

0045 Cookery

0016 Fashion Designing

Composite Key Student Registry Table

Student Registry Name Table Course Table