You are on page 1of 26

DITP 1333: WEEK 6

NORMALIZATION

PART 2
!
NORMALIZATION
!
!

• Functional dependencies!

• The process of normalization!

• First Normal Form (1NF)!

• Secon Normal Form (2NF)!

• Third Normal Form (3NF)!

!
Functional
NORMALIZATION
Dependency

Functional Dependency

Important concept associated with normalization are!


functional dependency and transitive dependency

Functional dependency describes relationship between!


attributes.
Functional
NORMALIZATION
Dependency

Functional Dependency and Keys

• Functional  dependency  is  a  constraint  between  2  attributes  or  2  sets  of  attributes  

• Functional  dependency  of  B  on  A  is  represented  by  an  arrow.  

• The  determinant  of  a  functional  dependency  refers  to  the  attribute  or  group  of  
attributes  on  the  left-­‐hand  side  of  the  arrow.

A B
• B  is  functionally  dependent  on  attribute    A  
• A  uniquely  determines  the  value  of  B
Functional
NORMALIZATION
Dependency

Functional Dependency and Keys

• An  attribute  may  be  functionally  dependent  on  


a  combination  of  two  (or  more)  attributes  
rather  than  on  a  single  attribute.

EMP COURSE (EmpID, Course_Title, DateCompleted)

EmpID, Course_Title DateCompleted

This  statement  implies  that  ….date  completed  is  determined  


by  the  employee_ID    and  the  Course_Title.
Functional
NORMALIZATION
Dependency

Functional Dependency and Keys

EMPLOYEE_1
EmpID Name DeptName Salary
100 Simpson Marketing 48000
140 Susan Accounting 52000
110 Lorenzo Info  System 43000
190 Allen Finance 55000
150 Dave Marketing 42000

EmpID Name DeptNam Salary This  statement  implies  that  ALL  


e of  the  attributes  are  
functionally  dependent  on  
EmpID.  Therefore,  EmpID  is  a  
EmpID Name, DeptName, Salary candidate  key  and  also  is  the  PK
Functional
NORMALIZATION
Dependency

Functional Dependency and Keys

EMPLOYEE_2
EmpID Course_Tittle Name DeptName Salary DateComplete Neither  EmpID  nor  
100 SPSS Simpson Marketing 48000
d
6/10/2014
CourseTitle  
uniquely  identifies  a  
140 Surveys Susan Accounting 52000 5/5/2014 row  in  this  relation  
110 Tax  Acc Lorenzo Info  System 43000 6/2/2014 and  therefore  
190 C++ Allen Finance 55000 15/8/2014
cannot  by  itself  be  a  
candidate  key.
150 Java Dave Marketing 42000 28/1/2015

EmpID Course_Tittle Name DeptName Salary DateCompleted

EmpID Name, DeptName, Salary


EmpID, Course_Title DateCompleted
Composite key
Functional
NORMALIZATION
Dependency

Transitive Dependency

TransiNve  dependency  describes  a  condiNon  where  A,  B,  and  


C  are  aQributes  of  a  relaNon  such  that  :  
!
if                          A  →  B    
and                  B  →  C  
then              C  is  transiQvely  dependent  on  A  via  B    
!
(provided  that  A  is  not  funcNonally  dependent  on  B  or  C).  
!
Important  to  recognize  a  transiQve  dependency  because  its  
existence  in  a  relaNon  can  potenQally  cause  update  
anomalies.
8
The proses of
NORMALIZATION
normalization

The Proses

PVFC  CUTOMER  INVOICE


Customer  ID   : C102 Order  ID :  1006
Customer  Name : Abu Suffian Order  Date :  10/24/2010
Address : 678 Hill Street, Marrickville

Product  
Product  ID Finish Quantity Unit  Price Extended  Price
Description

P45 Dining  Table Natural  Ash 3  $            500.00    $                      1,500.00  

P55 Writer's  Desk Cherry 5  $            800.00    $                      4,000.00  

P63 Sofa Natural  Maple 6  $            125.00    $                            750.00  

        Total  $                      6,250.00  
The proses of
NORMALIZATION
normalization

The Process : Step by Step

Objective of normalization is to ensure that


all tables are in at least 3NF

1NF 2NF 3NF


Relation:   Relation:  
• √ PK   •  √ 1NF   Relation;  
• NO  repeating   • NO  partial   •  √ 2NF  
group/   dependency  (Every   • NO  transitive  
multivalued   non-­‐key  attribute  is   dependencies
attributes fully  functionally  
dependent  on  PK  )
First Normal
NORMALIZATION
Form

UNF to 1NF

• Nominate  an  attribute  or  group  of  attributes  to  


act  as  the  key  for  the  non-­‐normalized  table.  
• Identify  the  repeating  groups  in  the  non-­‐
normalized  table  which  repeats  for  the  key  
attributes.  
• Remove  the  repeating  group  by  entering  
appropriate  data  into  the  empty  columns  of  
rows  containing  the  repeating    
data("flattening"  the  table)
First Normal
NORMALIZATION
Form

UNF to 1NF

Invoice  Data  (UNF)


Product
Order Order Customer Customer Customer Product Product Ordered
ProductID Standard
ID Date ID Name Address Description Finish Quantity
Price

1006 10/24/2010 C102 Abu  Suffian 678  Hill  Street,  


Dining  Table   Natural    
Marrickville P45 $            500.00   3
Ash

P55   Cherry   $            800.00    


Writer’s  Desk 5
Natural    
P63   Sofa   $            125.00    
Maple   6
 

1007 10/25/2010 C106 Zulkarnain 3  Brown  Street   $            200.00    


P15 Dresser    Table Oak 2
Manly  

P55   Writer’s  Desk   Cherry   $            800.00    


3

Natural  
P63   Sofa  
Maple   $            125.00 4
First Normal
NORMALIZATION
Form

UNF to 1NF

Invoice  Data  (1NF)


Product
Order Order Customer Customer Customer Product Product Ordered
ProductID Standard
ID Date ID Name Address Description Finish Quantity
Price

1006 10/24/2010 C102 Abu  Suffian 678  Hill  Street,  


Marrickville Dining  Table   Natural    
P45 $            500.00   3
Ash

1006 10/24/2010 C102 Abu  Suffian 678  Hill  Street,   P55   Cherry   $            800.00    
Writer’s  Desk 5
Marrickville
1006 10/24/2010 C102 Abu  Suffian 678  Hill  Street,   Natural    
P63   Sofa   $            125.00    
Marrickville Maple   6
 

1007 10/25/2010 C106 Zulkarnain 3  Brown  Street   $            200.00    


Manly P15 Dresser    Table Oak 2
 

1007 10/25/2010 C106 Zulkarnain 3  Brown  Street   P55   Writer’s  Desk   Cherry   $            800.00    
Manly 3

1007 10/25/2010 C106 Zulkarnain 3  Brown  Street   Natural  


Manly P63   Sofa  
Maple   $            125.00 4
The proses of
NORMALIZATION
normalization

Partial Dependency
!
!
Exists when there is a functional dependence in
which the determinant is only part of the primary key
!

PD

EmpID Course_Tittle Name DeptName Salary DateCompleted

PD

14
The proses of
NORMALIZATION
normalization

FD, TD and PD

Full  Dependency

Transitive  Dependency

Order Order Customer Customer Customer Product Product Product Ordered


ProductID Standard
ID Date ID Name Address Description Finish Quantity
Price

Partial  Dependency Partial    Dependency


The proses of
NORMALIZATION
normalization

Removing Partial Dependencies

3NF

OrderID ProductID Ordered  Quantity

2NF  ,  3NF

ProductID ProductDescription ProductFinish ProductStandardPrice

2NF

OrderID OrderDate CustomerID CustomerName CustomerAddress

Transitive  dependency
16
The proses of
NORMALIZATION
normalization

Removing Transitive Dependencies

2NF

OrderID OrderDate CustomerID CustomerName CustomerAddress

Transitive  dependency
3NF

OrderID OrderDate CustomerID

3NF

CustomerID CustomerName CustomerAddress

17
The proses of
NORMALIZATION
normalization

Normalized table in ERD

ORDER
CUSTOMER Places
PK Order_ID  
PK Customer_ID   !
! ! Order_Date  
Customer_Name   FK1 Customer_ID
Customer_Address

ERD  for  INVOICE  DATA


includes

PRODUCT
PK Product_ID   ORDER  LINE
!
Product_Description   Is  ordered PK,  FK1   Order_ID  
Product_Finish   PK,FK2 Product_ID  
Product_Standard_Price !Ordered_Quantity
18
SUMMARY

• Normalization  minimises  data  


redundancies  
!

• 1NF,  2NF  and  3NF  are  most  commonly  


encountered

23
DISCUSSION
Normalize  the  following  table.  Show  your  work  using  relational  schema.

UNF
PROJECT  

Project_   Project_   Emp_   Emp_  


Job_Class Chg_Hour Hours
Number Name Number Name

20
DISCUSSION SOLUTION

1NF
Full Dependency

PK PK

Project_   Project_   Emp_   Emp_   Job_Class Chg_Hour Hours


Number Name Number Name

Partial Dependency Transitive


Dependency
Partial Dependency
DISCUSSION SOLUTION

1NF

Project_Number,  Emp_Number                                  Project_Name,  Emp_Name,  


               Job_Class,Chg_Hour,Hours

Project_Number                                      Project_Name
PD
Employee_Number                              Emp_Name,Job_Class,Chg_Hour,Hours              
TD Job_Class                                                                Chg_Hour          

Relation:  
 √ PK  
NO  Repeating  group
DISCUSSION SOLUTION

2NF

1NF,  2NF,  3NF


Project_Number Project_Name

1NF,  2NF Transitive  Dependency


Emp_Number Emp_Name Job_Class Chg_Hour

1NF,2NF,3NF
Project_Number Emp_Number Hours

Relation:  
 √ 1NF  
NO  partial  dependency

23
DISCUSSION SOLUTION

3NF

1NF,  2NF Transitive  Dependency


Emp_Number Emp_Name Job_Class Chg_Hour

1NF,  2NF,  3NF

Emp_Number Emp_Name Job_Class

1NF,  2NF,  3NF


Relation:  
Job_Class Chg_Hour  √ 2NF  
NO  Transitive  
Dependency
24
DISCUSSION SOLUTION

3NF  Conversion  Result


PROJECT

Project_Number Project_Name PROJECT  (Project_Number  ,Project_Name)

EMPLOYEE

Emp_Number Emp_Name Job_Class EMPLOYEE  (Emp_Number  ,  


                                         Emp_Name,  Job_Class)
JOB

Job_Class Chg_Hour JOB  (Job_Class,  Chg_Hour)

ASSIGNMENT
ASSIGNMENT  (Project_Number,    
Project_Number Emp_Number Hours                                                      Emp_Number,  Hours)
DISCUSSION
Question 1:
The table shown in Figure 1 is susceptible to update anomalies. Provide examples of
insertion, deletion, and modification anomalies.
!
Question 2:
Describe and illustrate the process of normalizing the table shown in Figure 1 to 3NF.
State any assumptions you make about the data shown in this table.

24

You might also like