ITS232 Introduction To Database Management Systems: Normalization of Database Tables (Part II: The Process)
ITS232 Introduction To Database Management Systems: Normalization of Database Tables (Part II: The Process)
CHAPTER 5
Normalization Of Database Tables
(Part II: The Process)
Objectives
• How to undertake the process of normalization.
Data Redundancies
0NF/UNF
1NF
Normalization Denormalization
2NF
3NF
2
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process
If (exist)
First Normal Form = A relation in which the intersection of each row 1NF
and column contains one and only one value.
A relation is in 1NF if every attribute for every tuple have a value and
domain for each attribute can not be simplified anymore.
4
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 1NF
5
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 2NF
6
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 2NF
7
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 2NF
8
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 2NF
9
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 3NF
10
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 3NF
11
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 3NF
12
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 1NF
• Sample data is taken from two leases for two different clients called Rannia
and Ahmad and is transformed into table format with rows and columns, as
shown in Figure 3. This is an example of unnormalized table.
13
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 1NF
14
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 1NF
• There are multiple value at the intersection of certain rows and columns.
• e.g. there are two value for houseNo (PG4 and PG16) for the client Rannia.
• To transform an unnormalized table into 1NF, we ensure that there is a single value
at the intersection of each row and column. This is achieved by removing the
repeating group.
• With this approach, remove the repeating group (house rented details) by
entering the appropriate client data into each row.
• The resulting First Normalize Form (1NF) CLIENTRENTAL relation is shown in Figure
4.
16
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 1NF
Primary Key for the ClientRent relation is a composite key that are clientNO and houseNO
ClientRent relation is in 1NF as there is a single value at the intersection of each row and columns.
17
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: UNF 1NF
• Relationship in Figure 4 contains data that describes client, house for rent
and owner of the house, which is repeated for several times.
• As a consequences, the CLIENTRENTAL relation contains significant data
redundancy.
• If implemented, the 1NF relation would be subject to the update anomalies.
• To remove some of these, transform 1NF 2NF
18
Chapter 5: Normalization Of Database Tables
The decomposition of the ClientRental UNF 2NF
HouseOwner
• 2NF applies to relations with composite keys, that is, relations with PK
composed of two or more attributes.
20
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 1NF 2NF
21
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 1NF 2NF
fd3
(Partial dependency)
fd4
(Transitive dependency)
22
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 1NF 2NF
• Relational Schema
CLIENTRENTAL(clientNO, houseNO, cNAME, houseADD, rentSTART, rentFINISH, rent,
ownerNO, oNAME)
• Functional dependencies
23
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 1NF 2NF
24
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 1NF 2NF
25
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 1NF 2NF
RENTAL Figure 6 : 2NF
clientN0 houseN0 rentSTAR rentFINIS
CR76 PG04 T
1/7/93 H31/8/00
HOUSEOWNER
houseNO houseADD rent ownerNO oNAME
PG04 Skudai, Johor. 750 C040 Dolah
PG 36 Kuantan, Pahang. 1000 C093 Abdullah
CLIENT(clientNO, cNAME)
RENTAL(clientNO, houseNO, rentSTART, rentFINISH)
HOUSEOWNER(houseNO, houseADD, rent, ownerNO, oNAME)
These relation are in 2NF as every non-primary-key attribute is fully functional dependent on
26
the PK of the relation.
Chapter 5: Normalization Of Database Tables
The decomposition of the ClientRental UNF 2NF
Third Normal Form = A relation that is in 1NF and 2NF and which
(3NF) no non-primary-key attribute is transitively
dependent on the primary key.
28
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 2NF 3NF
29
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 2NF 3NF
• Guidelines:
– Identify transitive dependencies and identify determinant that is not
primary key (PK).
30
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 2NF 3NF
– RENTAL
fd1 clientNO, houseNO rentSTART, rentFINISH (Primary Key)
– CLIENT
fd2 clientNO Cname (Primary Key)
– HOUESOWNER
fd3 houseNO houseADD, rent, ownerNO, oNAME (Primary
key) fd4 ownerNO oNAME (Transitive
dependency)
31
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 2NF 3NF
• All the non-primary-key attributes within the CLIENT and RENTAL relations
are functionally dependent on their PK.
• The CLIENT and RENTAL relations have no transitive dependencies and
are therefore already in 3NF.
32
Chapter 5: Normalization Of Database Tables
5.3 The Normalization Process: 2NF 3NF
HOUSE
houseNO houseADD rent ownerNO
OWNER
PG04 Skudai, Johor. 750 C040 ownerNO oNAME
PG 36 Kuantan, Pahang. 1000 C093 C040 Dolah
33
Chapter 5: Normalization Of Database Tables
The decomposition of the ClientRental UNF 3NF
Figure 8 : The decomposition of the ClientRental 1NF relation into 3NF relations.
CLIENTRENTAL 1NF
HOUSEOWNER
HouseOwner 2NF
Client RENTAL
Rental HOUSE
HouseForRent OWNER
Owner 3NF
35
Chapter 5: Normalization Of Database Tables
A summary of the 3NF relation derived from ClientRental relation
Figure 9 : A summary of the 3NF relation derived from the ClientRental relation.
CLIENT RENTAL
clientNO cName clientNO houseNO rentSTAR rentFINIS
CR76 PG04 T
1/7/93 H
31/8/00
CR76 Rannia
These relation are in 3NF as every non-primary-key attribute is fully functional dependent on the PK of
the relation and have no transitive dependencies.
Chapter 5: Normalization Of Database Tables
A summary of the 3NF relation derived from ClientRental relation
Figure 10 : ERD for the 3NF relation derived from the ClientRental relation.
houseNo
1 M 1
CLIENT RENTAL HOUSE
M rent
clientNO clientNO houseNO
houseNO
rentSTART rentFINISH
cNAME have houseAD
ownerNO*
OWNER
CLIENT (clientNO, cNAME)
RENTAL (clientNO, houseNO, rentSTART, rentFINISH)
HOUSE (houseNO, houseADD, rent, ownerNO*)
OWNER (ownerNO, oNAME) ownerNO
oNAME 37
Chapter 5: Normalization Of Database Tables
General Definations of UNF, 1NF, 2NF & 3NF
38