0% found this document useful (0 votes)
23 views5 pages

Normalization Example

The document outlines the process of normalizing a database from unnormalized data through First, Second, and Third Normal Forms (1NF, 2NF, 3NF). It addresses issues such as repeating groups, partial dependencies, and transitive dependencies, and provides solutions by creating separate tables for orders, products, and product prices. The final structure ensures that each piece of data is stored only once, enhancing database efficiency and reducing redundancy.

Uploaded by

shazilgta6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views5 pages

Normalization Example

The document outlines the process of normalizing a database from unnormalized data through First, Second, and Third Normal Forms (1NF, 2NF, 3NF). It addresses issues such as repeating groups, partial dependencies, and transitive dependencies, and provides solutions by creating separate tables for orders, products, and product prices. The final structure ensures that each piece of data is stored only once, enhancing database efficiency and reducing redundancy.

Uploaded by

shazilgta6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Step 1: Unnormalized Data (Before Normalization)

Order Customer Produc ProductN Product Delivery ContactNu


ID Name tID ame Price Date mber
O001 Ali Khan P001, Laptop, 1000, 20 2024-12- 123-456-
P002 Mouse 10 7890
O002 Sara P003 Smartpho 800 2024-12- 987-654-
Ahmed ne 11 3210
O003 Ahmed P002, Mouse, 20, 50 2024-12- 456-789-
Khan P004 Keyboard 15 0123

Issues:

 Repeating groups: Multiple products in single cells


(e.g., ProductID, ProductName, and ProductPrice).
 Partial dependency: Product details are partially
dependent on the OrderID.
 Transitive dependency: Product information
(e.g., ProductName) depends on ProductID, which is
indirectly tied to the OrderID.

First Normal Form (1NF)

To meet 1NF, we need to ensure that:

 Each column contains atomic values (no repeating groups).


 Each record is unique.

Normalized Data in 1NF:

Orde Custome Produ Product Produc Deliver ContactN


rID rName ctID Name tPrice yDate umber
O00 Ali Khan P001 Laptop 1000 2024- 123-456-
1 12-10 7890
Orde Custome Produ Product Produc Deliver ContactN
rID rName ctID Name tPrice yDate umber
O00 Ali Khan P002 Mouse 20 2024- 123-456-
1 12-10 7890
O00 Sara P003 Smartp 800 2024- 987-654-
2 Ahmed hone 12-11 3210
O00 Ahmed P002 Mouse 20 2024- 456-789-
3 Khan 12-15 0123
O00 Ahmed P004 Keyboar 50 2024- 456-789-
3 Khan d 12-15 0123

Changes:

 The multiple products for each order are now split into separate rows,
ensuring atomicity (single values in each cell).
 OrderID repeats for each product in the order, but that's fine in 1NF.

Step 2: Second Normal Form (2NF)

To meet 2NF, we need to ensure:

 The data is already in 1NF.


 There are no partial dependencies (i.e., non-prime attributes should not
depend on part of the primary key).

Solution:
We need to separate the order-specific data into a separate table so
that ProductID is linked only to OrderID and ProductID.

Normalized Data in 2NF:

Orders Table:

OrderID CustomerName DeliveryDate ContactNumber


O001 Ali Khan 2024-12-10 123-456-7890
O002 Sara Ahmed 2024-12-11 987-654-3210
OrderID CustomerName DeliveryDate ContactNumber
O003 Ahmed Khan 2024-12-15 456-789-0123

Products Table:

ProductID ProductName ProductPrice


P001 Laptop 1000
P002 Mouse 20
P003 Smartphone 800
P004 Keyboard 50

OrderDetails Table:

OrderID ProductID
O001 P001
O001 P002
O002 P003
O003 P002
O003 P004

Changes:

 We created an Orders Table for customer and order-specific data


(i.e., OrderID, CustomerName, ContactNumber, DeliveryDate).
 We created a Products Table for product-specific data
(i.e., ProductID, ProductName, ProductPrice).
 The OrderDetails Table links products to orders
via OrderID and ProductID.

Step 3: Third Normal Form (3NF)

To meet 3NF, we need to ensure:

 The data is already in 2NF.


 There are no transitive dependencies (i.e., non-prime attributes should
not depend on other non-prime attributes).

Issues in 2NF:
In the Products Table, ProductName and ProductPrice are dependent
on ProductID, but ProductName and ProductPrice are directly related
to each other. This is a transitive dependency.

Solution:
We separate the ProductPrice from ProductName into another table,
ensuring that ProductName and ProductPrice are only dependent
on ProductID.

Normalized Data in 3NF:

Products Table:

ProductID ProductName
P001 Laptop
P002 Mouse
P003 Smartphone
P004 Keyboard

ProductPrices Table:

ProductID ProductPrice
P001 1000
P002 20
P003 800
P004 50
 We moved ProductPrice to a separate table called ProductPrices,
ensuring that it is only dependent on ProductID and eliminating
transitive dependencies.

Final Structure (After 3NF):


This is a normalized structure that eliminates repeating groups, partial
dependencies, and transitive dependencies. Each piece of data is stored
only once, making the database more efficient and less prone to
redundancy.

You might also like