Download - Normalization of Database Table
-
8/10/2019 Normalization of Database Table
1/17
Normalization of Database
Table
-
8/10/2019 Normalization of Database Table
2/17
Normalization is a systematic approach ofdecomposing tables by eliminate data redundancyand undesirable characteristics such as Insertion,Update and Deletion.Two main purpose:
Eliminating redundant (useless) dataEnsuring data dependencies make sense.
Normalization of Database
-
8/10/2019 Normalization of Database Table
3/17
Without normalization, it becomes difficult to handleand update the database.Insertion, Updating and Deletion are very frequent ifdatabase is not normalized.
Problem with Normalization
-
8/10/2019 Normalization of Database Table
4/17
S_id S_Name S_Address Subject_offered
401 Adam Kuala Lumpur Bio
402 Alex Ipoh Maths
403 Stuart Penang Maths
404 Adam Melacca Physics
Student Table
-
8/10/2019 Normalization of Database Table
5/17
A row of data cannot contain repeating group.Each row of data must have a unique identifier.Student_Subject Table
1NF
S_id S_Name Subject_offered
401 Adam Biology
401 Adam Physics
403 Alex Maths
404 Stuart Maths
-
8/10/2019 Normalization of Database Table
6/17
You can clearly see that student name Adam is used twice inthe table and subject maths is also repeated.To reduce above table to First Normal form break the tableinto two different tables.New Student Table:
S_id S_Name
401 Adam
403 Alex
404 Stuart
-
8/10/2019 Normalization of Database Table
7/17
Subject Table :
In Student table concatenation of subject_id andstudent_id is the Primary key .Now both table are normalized.
Subject_id Student_id Subject_offered
10 401 Biology
11 401 Physics12 402 Maths
12 403 Maths
-
8/10/2019 Normalization of Database Table
8/17
A table to be normalized to Second Normal Formshould meet all the needs of First Normal Form andthere must not be any partial dependency.If any column depends only on one part of theconcatenated key, then the table fail Second normal
form.
2NF
-
8/10/2019 Normalization of Database Table
9/17
Customer table:
Customer_id and Order_Id is the primary key.However this table are not in the Second Normal Form
because there are partial dependencies of columns onprimary key.
Customer_id Customer_Name Order_Id Order_Name
Sale_Detail
401 Adam 10 Order1 Sale1
401 Adam 11 Order2 Sale2402 Alex 12 Order3 Sale3
403 Stuart 13 order4 sale4
-
8/10/2019 Normalization of Database Table
10/17
To reduce Customer table to Second Normal Formbreak the table into following three different table:
Customer Detail TableCustomer_id Customer_Name
101 Adam
102 Alex102 Stuart
-
8/10/2019 Normalization of Database Table
11/17
Order Detail Table:
Sale_Detail:
Customer_id Order_id Sale_Detail101 10 Sale1
101 11 Sale2
102 12 Sale3
103 13 sale4
Order_id Order_name
10 Order1
11 Order2
12 Order3
13 Order4
-
8/10/2019 Normalization of Database Table
12/17
Third Normal Form applies that every non-primeattribute of table must be dependent on Primary Key.The transitive Functional Dependency should beremoved from the table.Table must be in second form.
3NF
-
8/10/2019 Normalization of Database Table
13/17
Student_Detail Table:
In this table Student_id is Primary Key.But street, city and state depends upon zip.
The dependency between zip and other fields is calledtransitive dependency.To apply 3NF we need to move the street, city and state tonew table
Student_Id Student_Name
DOB Street
City State Zip
-
8/10/2019 Normalization of Database Table
14/17
Student_Detail Table:
Student_Detail Table:
The advantages of removing transitive dependency:Amount of data duplication is reducedData integrity achieved.
Student_id Student_Name DOB Zip
Zip Street City State
-
8/10/2019 Normalization of Database Table
15/17
Example 1
-
8/10/2019 Normalization of Database Table
16/17
CUSTOMER (CustomerNo, CustomerName, Address,ItemCode, ItemDescription, Quantity, Price, Supplier,SupplierName)
Example 2
-
8/10/2019 Normalization of Database Table
17/17
OrderNo OrderDate ProductNo Descrption Quantity123 3/8/95 A3
A4
A2
Pen MerahPen Hijau
Pen Kuning
71
4234 5/7/95 A1
A3A1A3
123
345 12/7/95 A3 Pen Merah 144
Example 3