Handout 19 - Data NormalizationCaseSttudies
Handout 19 - Data NormalizationCaseSttudies
Lesson 19
Objectives
Case Studies
o Invoice
o StaffatBranch
o ArtGallary
o IssuedBook
Invoice
OrderN OorderDat CustormerI CustomerNam CustomerAd ProductI ProductDes ProductPric ProductQuantit
o e D e d D c e y
1 23/5/2012 1 Ali Rawalpindi 1 Shampoo 50 2
2 Soap 40 3
3 Detergent 110 1
4 Milk 89 2
2 23/5/2012 2 Ahmad Islamabad 1 Shampoo 50 2
6 LemonMax 33 3
3 Detergent 110 1
5 Chocolate 29 3
Above relation of Invoice is un-normalized; due to violating the property, atomic value
in relation.
This problem of atomicity can be solved by just filling the values as below.
Invoice
OrderN OrderDate CustormerID CustomerName CustomerAd ProductID ProductDesc ProductPrice ProductQuantity
o d
1 23/5/2012 1 Ali Rawalpindi 1 Shampoo 50 2
1 23/5/2012 1 Ali Rawalpindi 2 Soap 40 3
1 23/5/2012 1 Ali Rawalpindi 3 Detergent 110 1
1 23/5/2012 1 Ali Rawalpindi 4 Milk 89 2
2 23/5/2012 2 Ahmad Islamabad 1 Shampoo 50 2
2 23/5/2012 2 Ahmad Islamabad 6 LemonMax 33 3
2 23/5/2012 2 Ahmad Islamabad 3 Detergent 110 1
2 23/5/2012 2 Ahmad Islamabad 5 Chocolate 29 3
orderNo orderDate
orderNo customerID
orderNo customerName
orderNo customerAdd
orderNo, ProductID orderQuantity
customerID customerName
customerID customerAdress
productID productPrice
productID productDesc
MA/Handout 19 -2- Database Systems
There is no single attribute that has an ability to determine values of the remaining
attribute. From orderNo we cannot determine the value of productID uniquely.
Therefore a composite key is made by combining orderNo and productID. This
combination has capability to determine the values of remaining attributes uniquely. In
other words we can say that all of the remaining attributes are functionally dependent
on orderNo and productID. So the primary key will be ProductID and orderNo.
1NF
OrderN OrderDate CustormerID CustomerName CustomerAd ProductID ProductDesc ProductPrice ProductQuantity
o d
1 23/5/2012 1 Ali Rawalpindi 1 Shampoo 50 2
1 23/5/2012 1 Ali Rawalpindi 2 Soap 40 3
1 23/5/2012 1 Ali Rawalpindi 3 Detergent 110 1
1 23/5/2012 1 Ali Rawalpindi 4 Milk 89 2
2 23/5/2012 2 Ahmad Islamabad 1 Shampoo 50 2
2 23/5/2012 2 Ahmad Islamabad 6 LemonMax 33 3
2 23/5/2012 2 Ahmad Islamabad 3 Detergent 110 1
2 23/5/2012 2 Ahmad Islamabad 5 Chocolate 29 3
Partial dependencies can be resolved by placing all those attributes in separate relation
with copy of determinant: orderDate, customerID, customerName, customerAdd will
be placed in separate relation with determinant orderNo as
Order
OrderNo OrderDate CustormerID CustomerName CustomerAdd
1 23/5/2012 1 Ali Rawalpindi
2 23/5/2012 2 Ahmad Islamabad
And productPrice and ProductDesc are partially dependent and can be resolved as
Product
ProductID ProductDesc ProductPrice
1 Shampoo 50
2 Soap 40
3 Detergent 110
4 Milk 89
6 LemonMax 33
5 Chocolate 29
MA/Handout 19 -3- Database Systems
Invoice
OrderNo ProductI ProductQuantity
D
1 1 2
1 2 3
1 3 1
1 4 2
2 1 2
2 6 3
2 3 1
2 5 3
Given table is decomposed into three tables (Order, Product and Invoice). In all of three
there is no partial dependency so all of three relations are in 2NF.
3NF
To check whether the obtained tables are in 3NF or not. To do this we have to check
transitive dependencies in all three relations.
In Invoice and Product relation there is no transitive dependency so these two are in
3NF.
Customer
CustormerID CustomerName CustomerAdd
1 Ali Rawalpindi
2 Ahmad Islamabad
Order
OrderNo OrderDate CustormerID
1 23/5/2012 1
2 23/5/2012 2
Product
ProductID ProductDesc ProductPrice
1 Shampoo 50
2 Soap 40
3 Detergent 110
4 Milk 89
6 LemonMax 33
5 Chocolate 29
MA/Handout 19 -4- Database Systems
Invoice
OrderNo ProductI ProductQuantity
D
1 1 2
1 2 3
1 3 1
1 4 2
2 1 2
2 6 3
2 3 1
2 5 3
Customer
CustormerID CustomerName CustomerAdd
1 Ali Rawalpindi
2 Ahmad Islamabad
All of above four (Invoice, order, product and customer) are in 3NF