You are on page 1of 50

NORMALISATION

CHAPTER 3: NORMALISATION
Database Systems

Objective

At the end of this chapter, students should be able to :

 Define relation.
 Recognize problems in relational data model.
 Define normalization and the level of normalization.
 Identify the step in normalization.

2
CHAPTER 3: NORMALISATION
Database Systems

3.1.3 Problems In Relational Data Model

 There are 2 problems in relational data model :


- Anomalies
- Information Redundancy

(a) Anomalies
Anomalies - Errors or inconsistencies that may result when a user attempts to update
a table that contains redundant data.

Types of anomalies:
(i) Modification Anomalies
(ii) Insert Anomalies
(iii) Delete Anomalies

(b) Information Redundancy


Duplication of data due to storing the same data multiple times.

a) Update Anomalies

i) Modification Anomalies

STUDENT_COURSE
Student_ID Student_Name Address Course_Code Course_Name

S0144 Hamizah Mohamed Jln. Kg. Gajah ASDIM Associate Diploma in


Redzwan Interactive
Multimedia
S0149 Amjadi Abd. Mubin Bandar Baru CGMP200 Computer Power
Bangi 200 (Graphic and
Multimedia)
S0157 Nurazean Bt. Md. Tmn. Koperasi CITP100 Computer power 100
Sobri Polis (IT)
S0159 Aidil Akmar Hj. Tmn. Melawati CGMP200 Computer Power
Ayob 200 (Graphic and
Multimedia)
S0035 Syed Ahmad Rizal B. Jalan Puchong DIPCGR Diploma in Computer
Syed Abdul Razak Graphic and Design.

The Problem :

3
CHAPTER 3: NORMALISATION
Database Systems

If we want to update Course_Name Computer Power 200 (Graphic & Multimedia) to Computer Power
200 (Graphic) from STUDENT_COURSE table, we have to update all the rows of all students who
take that course. The problem is we have to update more than once.

The Solution :

Therefore, to avoid this problem, we have to separate the STUDENT_COURSE table as follows :

STUDENT
Student_ID Student_Name Address Course_Code

S0144 Hamizah Mohamed Jln. Kg. Gajah ASDIM


Redzwan
S0149 Amjadi Abd. Mubin Bandar Baru Bangi CGMP200
S0157 Nurazean Bt. Md. Sobri Tmn. Koperasi Polis CITP100
S0159 Aidil Akmar Hj. Ayob Tmn. Melawati CGMP200
S0035 Syed Ahmad Rizal B. Syed Jalan Puchong DIPCGR
Abdul Razak

COURSE
Course_Code Course_Name
ASDIM Associate Diploma in Interactive Multimedia
CGMP200 Computer Power 200 (Graphic )
CITP100 Computer power 100 (IT)
DIPCGR Diploma in Computer Graphic and Design

The process to update Course will occur once without affecting other records.

ii) Insert Anomalies

STUDENT_COURSE
Student_ID Student_name Address Course_Code Course_Name

S0144 Hamizah Mohamed Jln. Kg. Gajah ASDIM Associate Diploma in


Redzwan Interactive
Multimedia
S0149 Amjadi Abd. Mubin Bandar Baru CGMP200 Computer Power 200
Bangi (Graphic and
Multimedia)
S0157 Nurazean Bt. Md. Tmn. Koperasi CITP100 Computer power 100
Sobri Polis (IT)
S0159 Aidil Akmar Hj. Tmn. Melawati DIPCGR Diploma in Computer
Ayob Graphic and Design
S0035 Syed Ahmad Rizal B. Jalan Puchong CGMP200 Computer Power 200
Syed Abdul Razak (Graphic and
Multimedia)
(null) (null) (null) (null) Diploma in

4
CHAPTER 3: NORMALISATION
Database Systems

Information
Technology

The Problem :
If we want to insert a new Course_Code and Course_Name to the STUDENT_COURSE table, it is
necessary to enter no data (null) into the attribute for student (Student_ID, Student_Name, Address).
The problem is the primary key (Student_ID) cannot be null.

The Solution :

Therefore, to avoid this problem, we have to separate the STUDENT_COURSE table as follows :

STUDENT
Student_ID Student_Name Address Course_Cide
S0144 Hamizah Mohamed Jln. Kg. Gajah ASDIM
Redzwan
S0149 Amjadi Abd. Mubin Bandar Baru Bangi CGMP200
S0157 Nurazean Bt. Md. Sobri Tmn. Koperasi Polis CITP100
S0159 Aidil Akmar Hj. Ayob Tmn. Melawati CGMP200
S0035 Syed Ahmad Rizal B. Syed Jalan Puchong DIPCGR
Abdul Razak

COURSE

Course_Code Course_Name
ASDIM Associate Diploma in Interactive Multimedia
CGMP200 Computer Power 200 (Graphic)
CITP100 Computer power 100 (IT)
DIPCGR Diploma in Computer Graphic and Design
CGMP200 Diploma in Information Technology

Any insertion to the COURSE table will not affect to the primary key in STUDENT table.

iii) Delete Anomalies

STUDENT_COURSE
Student_ID Student_Name Address Course_Code Course_Name

S0144 Hamizah Mohamed Jln. Kg. Gajah ASDIM Associate Diploma


Redzwan in Interactive
Multimedia
S0149 Amjadi Abd. Mubin Bandar Baru CGMP200 Computer Power
Bangi 200 (Graphic and
Multimedia)
S0157 Nurazean Bt. Md. Sobri Tmn. Koperasi CITP100 Computer power
Polis 100 (IT)
S0159 Aidil Akmar Hj. Ayob Tmn. Melawati DIPCGR Diploma in
Computer
Graphic and

5
CHAPTER 3: NORMALISATION
Database Systems

Design
S0035 Syed Ahmad Rizal B. Jalan Puchong CGMP200 Computer Power
Syed Abdul Razak 200 (Graphic and
Multimedia)

The Problem :
When the Student_ID S0035 is deleted from STUDENT_COURSE table, information about any
Course_Code DIPCGR related to that student will also be deleted. That means no other Course_Code
DIPCGR remains in the database.

The Solution :
Therefore, to avoid this problem, we have to separate the STUDENT_COURSE table as follows :

STUDENT
Student_ID Student_Name Address Course_Code

S0144 Hamizah Mohamed Jln. Kg. Gajah ASDIM


Redzwan
S0149 Amjadi Abd. Mubin Bandar Baru Bangi CGMP200
S0157 Nurazean Bt. Md. Sobri Tmn. Koperasi Polis CITP100
S0035 Syed Ahmad Rizal B. Syed Jalan Puchong CGMP200
Abdul Razak

COURSE

Course_Code Course_Name

ASDIM Associate Diploma in Interactive Multimedia


CGMP200 Computer Power 200 (Grafik)
CITP100 Computer power 100 (IT)
DIPCGR Diploma in Computer Graphic and Design
CGMP200 Diploma in Information Technology

Any deletion from STUDENT table will not affect the data in COURSE table.

(b) Information Redundancy


- Duplication of data due to the storing of the same data multiple times.

STUDENT_SUBJECT
Student_ Student_Name Address Subject_Cod Subject_Name Credit_Hours
ID
e
S0144 Hamizah Mohamed Jln. Kg. Gajah ACT410 Computerised 4
Redzwan Accounting
S0149 Amjadi Abd. Mubin Bandar Baru ADM101 Internet 4

6
CHAPTER 3: NORMALISATION
Database Systems

Bangi Publishing
S0157 Nurazean Bt. Md. Sobri Tmn. Koperasi ADM101 Internet 4
Polis Publishing
S0159 Aidil Akmar Hj. Ayob Tmn. Melawati ADM301 Project 4
S0035 Syed Ahmad Rizal B. Jalan Puchong ADM101 Internet 4
Syed Abdul Razak Publishing

The Problem :

In the STUDENT_SUBJECT table there is redundant information. It shows that the details of
subject ADM101 (Internet Publishing) are repeated for every member of Student_ID enrolled for
that subject.
The solution :

Therefore, to avoid this problem, we have to separate the STUDENT_SUBJECT table as follows:

It shows that the subject information appears only once for each
3.2 Penormalan (Normalisation) subject in SUBJECT relation & only the Subject_Code is
repeated in the STUDENT_SUBJECT relation.

3.2 Normalisation

Normalisation

7
CHAPTER 3: NORMALISATION
Database Systems

A process for assigning attributes into table and reduces data redundancy and helps eliminate the data
anomalies that associated with poor database design (unnormalised).

Level of Normalisation

There are 3 level of normalisation :

First normal Form (1NF)


Second Normal Form (2NF)

Third Normal Form (3NF)

First Normal Form (1NF)


A relation where the intersection of each row and column contains no repeating values (only
one value).

Second Normal Form (2NF)


A relation that is in 1NF and every non-primary key attribute is fully functionally dependent on
the primary key.

Third Normal Form (3NF)


A relation in which based on the concept of transitive dependency.

8
CHAPTER 3: NORMALISATION
Database Systems

3.2.1 Steps in Normalisation

Table with repeating groups


(Unnormalised Form (UNF)) Remove repeating groups

First normal Form (1NF)

Identify Functional
Dependencies
Second Normal Form (2NF)

Remove Transitive
Third Normal Form (3NF) Dependencies

Example 1:
Steps in Normalisation

Table with repeating groups


(Unnormalised Form (UNF)) Remove repeating groups
(refer table 1.1) (refer Note 1.1)
(rujuk jadual 1.1)

First normal Form (1NF)


(refer table 1.2) Identify Functional
Dependencies
(refer Note 1.2)

(Second Normal Form (2NF)) Remove Transitive


(refer table 1.3) Dependencies
(refer Note 1.3)

(Third Normal Form9(3NF))


(refer table 1.4)
CHAPTER 3: NORMALISATION
Database Systems

Table 1.1
Unnormalised Form (UNF)

STUDENT
Student ID Student Subject Name Subject Credit Grade Address Course Coordinator
Name Code Hours
S0001 Azlina Computerised ACT410 4 A Sentul Diploma in Fazilah
Ahmad Accounting Information
Internet
Repetitive
ADM101
group 4 B Technology
Publishing 4
Graphic
Attributes that DesignmoreART210
contains than one value in eachC and every line.
Application
S0144 Amirul Graphic ART310 4 A Shah Alam Diploma in Ahmad
Hamdan Communication Computer
Introduction to ART230 2 B Graphic
graphic Design Design
Business BUS210 4 B
Organization

S0151 Mazlina Promotion ART410 4 C Shah Alam Associate Sahada


Yakub Design ART 210 4 Diploma in
Graphic Design A Interactive
Application BUS210 4 Multimedia
Business A
Organisation

STUDENT (Student_ID, Student_name, Subject_name , Subject_code, Credit_hour, Grade, Address, Course,


Coordinator)

The table above shows that Subject_name, Subject_code, Credit_hour and Grade fields which contains multiple
or more repeating values.

10
CHAPTER 3: NORMALISATION
Database Systems

Note 1.1:
Problems that occur in tables with repeating groups :
 It’s hard to know exactly which Credit_Hour
belongs to which Subject_Name.
 To find a record in the table is very difficult.

How to handle Repeating Groups?


 The repeating group can be handled by separating
Table 1.2:
Unnormalised Form (UNF) into First Normal
First Normal Form (1NF)
Form (1NF) as shown later.

STUDENT
Student ID Student Subject Grade Address Course Coordinator
Name code
S0001 Azlina ACT410 A Sentul Diploma in Information Fazilah
Ahmad Technology
S0001 Azlina ADM101 B Sentul Diploma in Information Fazilah
Ahmad Technology
S0001 Azlina ART210 C Sentul Diploma in Information Fazilah
Ahmad Technology
S0144 Amirul ART310 A Shah Alam Diploma in Computer Ahmad
Hamdan Graphic Design
S0144 Amirul ART230 B Shah Alam Diploma in Computer Ahmad
Hamdan Graphic Design
S0144 Amirul BUS210 B Shah Alam Diploma in Computer Ahmad
Hamdan Graphic Design
S0151 Mazlina ART410 C Shah Alam Associate Diploma in Sahada
Yakub Interactive Multimedia
S0151 Mazlina ART 210 A Shah Alam Associate Diploma in Sahada
Yakub Interactive Multimedia
S0151 Mazlina BUS210 A Shah Alam Associate Diploma in Sahada
Yakub Interactive Multimedia

STUDENT (Student_ID, Student_name, Subject_code, Grade, Address, Course, Coordinator)

SUBJECT
Subject_Code Subject_Name Credit_hour
ACT410 Computerised Accounting 4
QDM101 Internet Publishing 4
ART210 Graphic Design Application 4
ART310 Graphic Communication 4
ART230 Introduction to graphic Design 2
BUS210 Business Organization. 4
ART410 Promotion Design 4
11
SUBJECT (Subject_code, Subject_name, Credit_hour)
CHAPTER 3: NORMALISATION
Database Systems

Note 1.2 :
What is Functional Dependencies?
Functional Dependencies describe relationships between attributes in a relation.

A relationship between attributes in which one attribute or group of attribute determines the value of another in
the same table.

Example :
Consider microcomputers in a COSMOPOINT computer lab. Each has only one size of main memory. So
MemorySize is functionally dependent on ComputerSerialNumber.

How to write?
ComputerSerialNumber MemorySize

The attributes on the left side of the arrow are called determinants.

How to read?

“ComputerSerialNumber functionaly determines MemorySize”


or
“ComputerSerialNumber determines MemorySize”
or
“MemorySize is functionally dependent on ComputerSerialNumber”

12
CHAPTER 3: NORMALISATION
Database Systems

Note 1.2 :

Identify Functional Dependencies

Student_ID Student_name Subject_code Grade Address Course Coordinator

Subject_code Subject_name Credit_hour

Student_ID Student_name, Address, Course, Coordinator


Subject_code Subject_name, Credit_hour
Student_ID, Subject_code Grade

Based on these 3 relations schema, there will be 3 tables (relations) in 2NF.

13
CHAPTER 3: NORMALISATION
Database Systems

Table 1.3
Second Normal Form (2NF)

STUDENT
Student_ID Student_name Address Course Coordinator
S0001 Azlina Ahmad Sentul Diploma in Information Technology Fazilah
S0144 Amirul Shah Diploma in Computer Graphic Design Ahmad
Hamdan Alam
S0151 Mazlina Yakub Shah Associate Diploma in Interactive Sahada
Alam Multimedia
STUDENT (Student_ID, Student_name, Address, Course, Coordinator)

SUBJECT
Subject_code Subject_name Credit_hour
ACT410 Computerised Accounting 4
QDM101 Internet Publishing 4
ART210 graphic Design Application 4
ART310 Graphic Communication 4
ART230 Introduction to graphic Design 2
BUS210 Business Organization. 4
ART410 Promotion Design 4
Subject (Subject_code, Subject_name, Credit_hour)

STUDENT_GRADE
Student_ID Subject_code Grade
S0001 ACT410 A
S0001 QDM101 B
S0001 ART210 C
S0144 ART310 A
S0144 ART230 B
S0144 BUS210 B
S0151 ART410 C
S0151 ART210 A
S0151 BUS210 A
STUDENT_GRADE (Student_ID, Subject14
_code, Grade)
CHAPTER 3: NORMALISATION
Database Systems

Note1.3:

What is Transitive Dependencies?

 A functional dependency between 2 or more non-key attributes. A condition in which an attribute is


dependent on another attributes that is not part of the primary key.
 A relation is in Third Normal Form (3NF) if it is in 2NF and has no transitive dependency.
 Non-primary key attribute is functionally dependent on another non-primary key attribute.

Transitive Dependencies

Student_ID Student_name Subject_code Grade Address Course Coordinator

Subject_code Subject_name Credit_hour

Student_ID Student_name, Address, Course, Coordinator

Student_ID, Subject_code Grade


Transitive Dependencies

Subject_code Subject_name, Credit_hour

15
CHAPTER 3: NORMALISATION
Database Systems

Note 1.3 :

Solution : In order to build 3NF table (relation), you have to remove the transitive dependencies.

Student_ID Student_name, Address, Course, Coordinator

Transitive Dependencies
Becomes

Student_ID Student_name, Address, Course


2 tables (relation) are created
Course Coordinator

So, there will be 4 tables in 3NF as shown below :

Student_ID Student_name, Address, Course


Student_ID, Subject_code Grade
Subject_code Subject_name, Credit_hour
Course Coordinator

16
CHAPTER 3: NORMALISATION
Database Systems

17
CHAPTER 3: NORMALISATION
Database Systems

Table 1.4

Third Normal Form (3NF)

STUDENT
Student_ID Student_name Address Course
S0001 Azlina Ahmad Sentul Diploma in Information Technology
S0144 Amirul Hamdan Shah Alam Diploma in Computer Graphic Design
S0151 Mazlina Yakub Shah Alam Associate Diploma in Interactive Multimedia
STUDENT (Student_ID, Student_name, Address,Course)

SUBJECT
Subject_code Subject_name Credit_hour
ACT410 Computerised Accounting, 4
ART310 Graphic Communication 4
ART410 Promotion Design 4
ART230 Introduction to graphic Design 2
BUS210 Business Organization 4
QDM101 Internet Publishing 4
ART210 Graphic Design Application 4
SUBJECT(Subject_code, Subject_name, Credit_hour)

COURSE
Course Coordinator
Diploma in Information Technology Fazilah
Diploma in Computer Graphic Design Ahmad
Associate Diploma in Interactive Multimedia Sahada
COURSE (Course, Coordinator)

STUDENT_GRADE
Student_ID Subject_code Grade
S0001 ACT410 A
S0001 ADM101 B
S0001 ART210 C
S0144 ART310 A
S0144 ART230 B
S0144 BUS210 B
S0151 ART410 C
S0151 ART 210 A
S0151 BUS210 A

18
CHAPTER 3: NORMALISATION
Database Systems

Example 2 :

Table 2.1 :
Unnormalised Table (UNF)

Table with repeating groups /


INVOICE
Unnormalised Form (UNF). Remove repeating groups
(refer table 2.1) (refer Note 2.1) Supplier
Customers Customer Address Item Item Qty Price Supplier
no name code desc _Address
A100 Abu Sentul KB100 Keyboard 20 25 XYZ Ent Petaling Jaya
First normal form (1NF)
CP200 CPU 10 650 XYZ Ent Petaling Jaya
(refer table 2.2) Identify Functional Dependencies.
MS112 Mouse 2 15 Note 2.2)
(refer XYZ Ent. Petaling Jaya

A101 Salmah Ampang HD200 Hard Disk 10 100 Seagate Pulau Pinang
Second Normal Form (2NF)
KB100 Keyboard 10 25 XYZ Ent Petaling Jaya
(refer table 2.3)
SP360 Speaker 5 45 XYZ Ent Petaling Jaya
Remove Transitive Dependencies
(refer note 2.3)
102 Rani Ampang MS112
Third Normal Mouse
Form (3NF) 4 15 XYZ Ent Petaling Jaya
(refer tableCP200
2.4) CPU 2 650 XYZ Ent Petaling Jaya
VG400 VGA Card 2 200 XYZ Ent Petaling Jaya

INVOICE (Customer_no, Customer_name, Address, Item_code, Item_desc, Qty, Price, Supplier, Supplier_address)

The table above shows that Item_code, Item_desc, Qty, Price, Supplier & Supplier_address fields contain
multiple or repeating values.
Assumption : One supplier supply many products.

19
CHAPTER 3: NORMALISATION
Database Systems

Table 2.2
First Normal Form (1NF)

CUSTOMER
Customer_no Customer_name Address
A100 Abu Sentul
Note 2.1:A101 Salmah Ampang
ProblemsA102
that occur in table with repeating Rani
groups Ampang
:
CUSTOMER (Customer_No,Customer_name,Address)
 It’s hard to know exactly which Item_Code
belongs to which Item_Desc.
INVOICE
 To find a record in the table is very difficult.
Customer_no Item_code Item_desc Qty Price Supplier Supplier_address

A100
How to handleKB100 Keyboard
Repeating Groups? 20 25 XYZ Ent. Petaling Jaya
A100
 CP200 group can
The repeating CPU be handled10 by 650 XYZ Ent. Petaling Jaya
A100 separatingMS112
UnnormalisedMouse
Form (UNF)2 into 15 XYZ Ent. Petaling Jaya
First Normal Form (1NF) as shown later.
A101 HD200 Hard Disc 10 100 Seagate Pulau Pinang
A101 KB100 Keyboard 10 25 XYZ Ent. Petaling Jaya
A101 SP360 Speaker 5 45 XYZ Ent. Petaling Jaya
A102 MS112 Mouse 4 15 XYZ Ent. Petaling Jaya
A102 CP200 CP 2 200 XYZ Ent. Petaling Jaya
A102 VG400 VGA Card 2 650 XYZ Ent. Petaling Jaya
INVOICE (Customer_no, Item_code, item_desc, Qty, Price, Supplier, Supplier_address)

The table above shows that each row contains a single value.
20
CHAPTER 3: NORMALISATION
Database Systems

Note 2.2
Identify Functional Dependencies.

What is Functional Dependencies?


Functional Dependencies describe relationships between attributes in a relation.

A relationship between attributes in which one attribute or group of attribute determines the value of another in
the same table.

Customer_no Customer_name Address

Customer_no Item_code Item_desc Qty Price Supplier Supplier_address

Customer_no Customer_name, Address,


Item_code Item_desc, Price, Supplier,Supplier_Address
Customer_no, Item_code Qty

Based on these 3 functional dependencies, there will be 3 tables (relations) in 2NF.

21
CHAPTER 3: NORMALISATION
Database Systems

Table 2.3

Second Normal Form (2NF)

CUSTOMER
Customer_no Customer_name Address
A100 Abu Sentul
A101 Salmah Ampang
A102 Rani Ampang
CUSTOMER (Customer_no, Customer_name, Address)

ITEM
Item_code Item_desc Price Supplier Supplier_Address

KB100 Keyboard 25 XYZ Ent. Petaling Jaya


HD200 Hard Disc 100 Seagate Pulau Pinang

MS112 Mouse 15 XYZ Ent. Petaling Jaya


SP360 Speaker 45 XYZ Ent. Petaling Jaya
CP200 CPU 650 XYZ Ent. Petaling Jaya
VG400 VGA Card 400 XYZ Ent. Petaling Jaya
ITEM (Item_code, Item_desc, Price, Supplier, Supplier_Address)

INVOICE
Customer_no Item_code Qty

A100 KB100 20
A100 CP200 10
A100 MS112 2

A101 HD200 10
A101 KB100 10
A101 SP360 5
A102 MS112 4
A102 CP200 22 2
A102 VG400 2
CHAPTER 3: NORMALISATION
Database Systems

Nota 2.3:

Transitive Dependency
 A functional dependency between 2 or more non-key attributes. A condition in which an attribute is
dependent on another attributes that is not part of the primary key.
 A relation is in Third Normal Form (3NF) if it is in 2NF and has no transitive dependency.
 Non-primary key attribute is functionally dependent on another non-primary key attribute.

Identify Functional Dependencies.

Customer_no Customer_name Address

Customer_no Item_code Item_desc Qty Price Supplier Supplier Address

Customer_no Cust_Name, Cust_Address


Customer_No, Item_Code Qty
Item_Code Item_Desc, Price, Supplier, Supplier_address

23
CHAPTER 3: NORMALISATION
Database Systems

Transitive Dependencies

Transitive Dependencies

24
CHAPTER 3: NORMALISATION
Database Systems

Solution: In order to build 3NF table (relation), you have to remove the transitive dependencies.

Item_code Item_desc, Price, Supplier,Supplier_address

Transitive Dependencies
Becomes

Item_code Item_desc, Price,Supplier


2 table (relation) are
Supplier Supplier_address created

So, there will be 4 tables in 3NF as shown below:

Customer_no Customer_name, Address


Customer_no, Item_code Qty
Item_code Item_desc,Price, Supplier
Supplier Supplier_address

25
CHAPTER 3: NORMALISATION
Database Systems

Table 2.4
Third Normal Form (3NF)

CUSTOMER
Customer_no Customer_name Address
A100 Abu Sentul
A101 Salmah Ampang
A102 Rani Ampang
CUSTOMER (Customer_no, Customer_name, Address)
Example 3 :

INVOICE
The Steps in Normalisation
Customer_no Item_code Qty

A100 KB100 20
A100 CP200 10
A100 MS112 2

A101 HD200 10
A101 SP360 5
A101 KB100 10
A102 MS112 4
A102 CP200 2
A102 VG400 2
INVOICE (Customer_no, Item_code, Qty)

ITEM
Item_code Item_desc Price Supplier

KB100 Keyboard 25 XYZ Ent.


HD200 Hard Disc 100 Seagate

MS112 Mouse 15 XYZ Ent.


SP360 Speaker 45 XYZ Ent.
CP200 CPU 650 XYZ Ent.
VG400 VGA Card 200 XYZ Ent.
ITEM (Item_code, Item_desc,Price, Supplier)

SUPPLIER
Supplier Supplier_address

XYZ Ent. Petaling Jaya

26
CHAPTER 3: NORMALISATION
Database Systems

Table with repeating groups (UNF)


(refer table 3.1)
Remove repeating groups
(refer note 3.1)

First normal form (1NF)


(refer table 3.2)
Table 3.1 Identify Functional Dependencies
(refer note 3.2)
Second
Unnormalised Form normal
(UNF) form (2NF)
(refer table 3.3)

PROJECT
Remove Transitive Dependencies
Project_no Third normal Staff_no
Project_name form (3NF) Staff_name Job_classification
(refer note 3.3) Charge_hour Hour
(refer table 3.4)
1 DADD 00689 Samat Elect.Engineer RM 20 20
00500 Ali Web Developer RM 22 18
00444 Azie Web Developer RM 22 15

2 Programming 00123 Kamal System Analyst RM 25 30


00999 Hazlim Technical Support RM 16 56

3 Multimedia 00689 Samat Elect.Engineer RM 20 40


00111 Anaz Programmer RM 18 35

PROJECT (Project_no, Staff_no, Project_name, Staff_name, Job_classification, Charge_hour, Hour)

The above table shows fields (Staff_no, Staff_name, Job_classification, Charge_hour & Hour) which have
Repeating Values.

27
CHAPTER 3: NORMALISATION
Database Systems

Note 3.1:
Problems that occur in tables with repeating
groups :
Table 3.2
 It’s hard to know exactly which Staff_no
First Normal Form (1NF)
belongs to which Staff_name.
 To find a record in the table is very difficult.
PROJECT
Project_noHow to handle
Project_
RepeatingStaff_no
Groups? Staff_name Job_ Charge_ hour
name classification hour
The repeating groups can be handled by
1 DADD 00689 Samat Elect.Engineer RM 20 20
separating Unnormalised Form (UNF) into First
1 DADD 00500 Ali Web Developer RM 22 18
Normal Form (1NF) as shown later.
1 DADD 00444 Azie Web Developer RM 22 15
2 Programming 00123 Kamal System Analyst RM 25 30
2 Programming 00999 Hazlim Technical RM 16 56
Support
3 Multimedia 00689 Samat Elect.Engineer RM 20 40
3 Multimedia 00111 Anaz Programmer RM 18 35

PROJECT (Project_no, Staff_no, Project_name, Staff_name, Job_classification, Charge_hour, Hour)

The above table shows that each row has its own value.

28
CHAPTER 3: NORMALISATION
Database Systems

Note 3.2:

What is Functional Dependencies?

Functional Dependencies describe relationships between attributes in a relation.

A relationship between attributes in which one attribute or group of attribute determines the value of another in
the same table.

Identify Functional Dependencies

Project_no Project_name Staff_no Staff_name Job_classification Charge_hour Hour

Project_no Project_name
Staff_no Staff_name, Job_classification, Charge_hour
Staff_no, Project_no Hour

Based on these 3 functional dependencies, there will be 3 tables (relations) in 2NF.

29
CHAPTER 3: NORMALISATION
Database Systems

Table 3.3 :

Second Normal Form (2NF)

PROJECT
Project_no Project_name
1 DADD
2 Programming
3 Multimedia
PROJECT (Project_no, Project_name)

STAFF
Staff_no Staff_name Job_classification Charge_hour

00689 Samat Elect.Engineer RM 20


00500 Ali Web Developer RM 22

00444 Azie Web Developer RM 22


00123 Kamal System Analyst RM 25
00999 Hazlim Technical Support RM 16
00111 Anaz Programmer RM 18
STAFF (Staff_no, Staff_name, Job_classification, Charge_hour)

HOUR
Staff_no Project_no Hour

00689 1 20
00500 1 18
00444 1 15

00123 2 30
00999 2 56
00689 3 40
00111 3 35
HOUR (Staff_no, Project_no, Hour)

30
CHAPTER 3: NORMALISATION
Database Systems

Note 3.3:

Transitive Dependency
 A functional dependency between 2 or more non-key attributes. A condition in which an attribute is
dependent on another attribute that is not part of the primary key.
 A relation is in Third Normal Form (3NF) if it is in 2NF and has no transitive dependency.
 Non-primary key attribute is functionally dependent on another non-primary key attribute.

Identify Transitive Dependencies

Project_no Project_name Staff_no Staff_name Job_classification Charge_hour Hour

Project_no Project_name
Staff_no Staff_name, Job_classification, Charge_hour
Staff_no, Project_no Hour

31
CHAPTER 3: NORMALISATION
Database Systems

Transitive Dependencies

Solution: In order to build 3NF table (relation), you have to remove the transitive dependencies.

Staff_no Staff_name, Job_classification, Charge_hour

Transitive Dependencies

Becomes
Transitive Dependencies

Staff_no Staff_name, Job_classification 2 tables


(relation) are
Job_classification Charge_hour created

So, there will be 4 tables in 3NF as shown below:

Project_no Project_name
Staff_no, Project_no Hour
Staff_no Staff_name, Job_classification

32
CHAPTER 3: NORMALISATION
Database Systems

Table 3.4
Third Normal Form (3NF)

PROJECT
Project_no Project_name
1 DADD
2 Programming
3 Multimedia
PROJECT (Project_no, Project_name)

STAFF
Staff_no Staff_name Job_classification

00689 Samat Elect.Engineer


00500 Ali Web Developer

00444 Azie Web Developer


00123 Kamal System Analyst
00999 Hazlim Technical Support
00111 Anaz Programmer
STAFF (Staff_no, Staff_name, Charge_hour, Job_classification)

HOUR
Staff_no Project_no Hour

00689 1 20
00500 1 18
00444 1 15

00123 2 30
00999 2 56
00689 3 40
00111 3 35
HOUR (Staff_no, Project_no, Hour)

JOB
Job_classification Charge_hour

Elect.Engineer RM 20
Web Developer RM 22
System Analyst RM 25
Technical Support RM 16 33
Programmer RM 18
JOB (Job_classification, Charge_hour)
CHAPTER 3: NORMALISATION
Database Systems

Example 4:

Normalised the table below from UNF to 3NF.

StaffID Name Dept Salary CourseID CourseTitle EndDate


100 Margaret Simpson Marketing 48000 101 SPSS 19 Jul 2003
102 Surveys 10 Aug 2003

140 Alan Beeton Accounting 52000 103 Tax Acc 8 Dec 2003
110 Chris Lucera Info Systems 43000 101 SPSS 1 Dec 2003
104 C++ 14 Nov 2003
190 Lorenzo Davis Finance 55000
150 Susan Martin Marketing 42000 101 SPSS 16 Jun 2003
105 Java 12 Aug 2003

UNF

COURSE (StaffID, Name, Dept, Salary, CourseID, CourseTitle, EndDate)

Table in UNF consist of redundant data and it must be transform to 1NF.

34
CHAPTER 3: NORMALISATION
Database Systems

First Normal Form (1NF)

STAFF
StaffID Name Dept Salary
100 Margaret Simpson Marketing 48000
110 Chris Lucera Info Systems 43000
140 Alan Beeton Accounting 52000
190 Lorenzo Davis Finance 55000
150 Susan Martin Marketing 42000

STAFF ( StaffID, Name, Dept, Salary)

COURSE
StaffID CourseID CourseTitle EndDate
100 101 SPSS 19 Jul 2003
100 102 Surveys 10 Aug 2003
110 101 SPSS 1 Dec 2003
110 104 C++ 14 Nov 2003
140 103 Tax Acc 8 Dec 2003
190
150 101 SPSS 16 Jun 2003
150 105 Java 12 Aug 2003

COURSE (StaffID, CourseID, CourseTitle, EndDate)

Table in 1NF is the situation where the intersection of each row and column contains no repeating values (only
one value).

Table in 1NF must be transform to 2NF by identify the functional dependencies.

35
CHAPTER 3: NORMALISATION
Database Systems

What is Functional Dependencies?


Functional Dependencies describe relationships between attributes in a relation.

A relationship between attributes in which one attribute or group of attribute determines the value of another in
the same table.

Identify Functional Dependencies

StaffID Name Dept Salary

StaffID CourseID CourseTitle EndDate

Based on these 3 functional dependencies, there will be 3 tables (relations) in 2NF.

StaffID Name, Dept, Salary


StaffID, CourseID EndDate
CourseID CourseTitle

36
CHAPTER 3: NORMALISATION
Database Systems

Second Normal Form (2NF)

STAFF
StaffID Name Dept Salary
100 Margaret Simpson Marketing 48000
110 Chris Lucera Info Systems 43000
140 Alan Beeton Accounting 52000
190 Lorenzo Davis Finance 55000
150 Susan Martin Marketing 42000
STAFF ( StaffID, Name, Dept, Salary)

STAFFCOURSE
StaffID CourseID EndDate
100 101 19 Jul 2003
100 102 10 Aug 2003
110 101 1 Dec 2003
110 104 14 Nov 2003
140 103 8 Dec 2003
190
150 101 16 Jun 2003
150 105 12 Aug 2003
COURSE (StaffID, CourseID, EndDate)

COURSE
CourseID CourseTitle
101 SPSS
102 Surveys
101 SPSS
104 C++
103 Tax Acc

101 SPSS
105 Java
COURSE (CourseID, CourseTitle)

Table in 1NF must be transform to 2NF by identify the transitive dependency.


37
CHAPTER 3: NORMALISATION
Database Systems

Transitive Dependency
 A functional dependency between 2 or more non-key attributes. A condition in which an attribute is
dependent on another attributes that is not part of the primary key.
 A relation is in Third Normal Form (3NF) if it is in 2NF and has no transitive dependency.
 Non-primary key attribute is functionally dependent on another non-primary key attribute.

Identify Transitive Dependencies

StaffID Name Dept Salary

StaffID CourseID EndDate

CourseID CourseTitle

There is no transitive dependencies in the relation.

3NF are :

STAFF ( StaffID, Name, Dept, Salary)


COURSECOURSE (StaffID, CourseID, EndDate)
COURSE (CourseID, CourseTitle)

38
CHAPTER 3: NORMALISATION
Database Systems

Example 5:

Normalise the following form to Third Normal Form (3NF). You are required to show the normalisation steps
taken. Provide your answer in a relation scheme.

Solution:
The Steps in Normalisation:
 Name the appropriate relation name.
 List down all attributes involved.

Relation Scheme Format:

39
CHAPTER 3: NORMALISATION
Database Systems

NZ SDN. BHD
RECEIPT OF HOUSE RENTAL PAYMENT

TENANT’S NAME : Nurul Atiqah TENANT’S CODE: 123


a) Unnormalised Form (UNF)

House_codeAddressStart_
Relation scheme in an Unnormalised Form :
dateEnd_dateRentalLandlord_code
Landlord
RENTAL (Tenant_code, Tenant_name, House_code, Address, Start_date, End_date, Rental, Landlord_code,
Landlord_name)
_namePG 3No. 6 Taman Tenaga, Kajang1/7/199531/7/1997RM 600T0069Intan bt.
JaafarPG 14No. 5 Taman Cahaya, Cheras1/8/19971/8/1999RM 650T8881Noor bt.
Nazri
b) First Normal Form (1NF)
 Make sure there is no redundant data in relation.
 Underline Primary Key.

Relation Scheme in 1NF:

CUSTOMER(Tenant_code, Tenant_name)

RENTAL (Tenant_code, House_code, Address, Start_date, End_date, Rental, Landlord_code, Landlord_name)

c) Second Normal Form (2NF)


Identify the Functional Dependencies (relationship among attributes in a relation).

Identify Functional Dependencies

CUSTOMER(Tenant_code, Tenant_name)
Relation Name (Primary Key, Non-key Attributes)

RENTAL (Tenant_code, House_code, Address, Start_date, End_date, Rental, Landlord_code, Landlord_name)

Relation Scheme in 2NF:

CUSTOMER(Tenant_code, Tenant_name)

RENTAL (Tenant_code, House_code, Start_date, End_date)

HOUSE (House_code, Address, Rental, Landlord_code,


40 Landlord_name)
CHAPTER 3: NORMALISATION
Database Systems

d) Third Normal Form (3NF)

Identify Transitive Dependencies

CUSTOMER(Tenant_code, Tenant_name)

Functional dependencies
RENTAL (Tenant_code, House_code, Start_date, End_date)

HOUSE (House_code, Address, Rental, Landlord_code, Landlord_name)

Transitive dependency

Relation Scheme in 3NF:

CUSTOMER(Tenant_code, Tenant_name)

RENTAL (Tenant_code, House_code, Start_date, End_date)

HOUSE (House_code, Address, Rental, Landlord_code)

LANDLORD (Landlord_code, Landlord_name)

41
CHAPTER 3: NORMALISATION
Database Systems

Example 6 :
Normalise the following form to Third Normal Form (3NF).

Solution:
The Steps in Normalisation:
 Name the appropriate relation name.
KOLEJ MILENNIUM
 List down all attributes involved. GRADE REPORT
SEMESTER MAY – AUGUST 2002
Relation Scheme Format:
Name : Emily Williams Major : MIS
Student No : 053-6929-24 Status : Senior
Address : 208 Brooks Hall

Subject Code Subject Name Professor ProfDept Grade


MIS 403 System Analysis Kendall, K DESC A
MIS 411 Conceptual Kendall, J DESC A
Foundations
MIS 420 Human Factors Kendall, J DESC B
in IS
CIS 412 Database Design Sibley, E CIS A
DESC 353 Management Kelly, D DESC A
Models
42
CHAPTER 3: NORMALISATION
Database Systems

a) Unnormalised Form (UNF)

Relation scheme in an Unnormalised Form :

STUDENT (Name, StudentNo, Address, Major, Status, Subject Code, SubjectName, Professor, ProfDept, Grade,
Semester)

First Normal Form (1NF)


Make sure there is no redundant data in relation.
Underline Primary Key.

Relation Scheme in 1NF:

STUDENT (StudentNo, Name, Address, Major, Status)

STUDENTSUBJECT (StudentNo, Subject Code, SubjectName, Professor, ProfDept, Grade, Semester)

c) Second Normal Form (2NF)

Identify the Functional Dependencies (relationship among attributes in a relation).


Relation Name (Primary Key, Non-key Attributes)

STUDENT (StudentNo, Name, Address, Major, Status)

STUDENTSUBJECT (StudentNo, Subject Code, SubjectName, Professor, ProfDept, Grade, Semester)

Relation Scheme in 2NF:

STUDENT (StudentNo, Name, Address, Major, Status)

GRADEREPORT (StudentNo, Subject Code, Grade, Semester)

SUBJECT (Subject Code, SubjectName, Professor, ProfDept)


43
CHAPTER 3: NORMALISATION
Database Systems

d) Third Normal Form (3NF)

Identify Transitive Dependencies

STUDENT (StudentNo, Name, Address, Major, Status)

GRADEREPORT (StudentNo, Subject Code, Grade, Semester)

SUBJECT (Subject Code, SubjectName, Professor, ProfDept)


Functional dependency

Transitive dependency

Relation Scheme in 3NF:

STUDENT (StudentNo, Name, Address, Major, Status)

GRADEREPORT (StudentNo, Subject Code, Grade, Semester)

SUBJECT (Subject Code, SubjectName, Professor)

PROF (Professor, ProfDept)

44
CHAPTER 3: NORMALISATION
Database Systems

Example 7 :
Normalise the following form to Third Normal Form (3NF).

AR SDN BHD
Solution: 32, JALAN KELANA,
The Steps in Normalisation: 50567 PETALING JAYA,
SELANGOR DARUL EHSAN
 Name the appropriate relation name.
NO TEL : 03-7552525
 List down all attributes involved.

CustomerNo
Relation Scheme: Format:
PNOO65 Invoice No : KS2345
Name : Ferhad Ibrahim Date : 2/3/2003
Address : Jalan Klang Lama
Tel No : 03 -2235990

ProductCode ProductName PriceUnit Quantity Discount SubTotal

A2345 Book 2.00 100 10% 180.00


B1235 Pen 0.25 500 125.00
D4568 Eraser 0.1 200 20.00
45 Total 325.00
CHAPTER 3: NORMALISATION
Database Systems

a) Unnormalised Form (UNF)

Relation scheme in an Unnormalised Form :

INVOICE (InvoiceNo, Date, CustomerNo, Name, Address, TelNo, ProductCode, ProductName, PriceUnit, Quantity,
Discount, Subtotal)

b) First Normal Form (1NF)


 Make sure there is no redundant data in relation.
 Underline Primary Key.

Relation Scheme in 1NF:

INVOICE (InvoiceNo, Date, CustomerNo, Name, Address, TelNo)

PRODUCT (InvoiceNo , ProductCode, ProductName, PriceUnit, Quantity, Discount, Subtotal)

c) Second Normal Form (2NF)


Identify the Functional Dependencies (relationship among attributes in a relation).

Relation Name (Primary Key, Non-key Attributes)

INVOICE (InvoiceNo, Date, CustomerNo, Name, Address, TelNo)

PRODUCT (InvoiceNo ,ProductCode, ProductName, PriceUnit, Quantity, Discount, Subtotal )

Relation Scheme in 2NF:

INVOICE (InvoiceNo, Date, CustomerNo, Name, Address, TelNo)

PRODUCT (ProductCode, ProductName, PriceUnit )

46
ORDER (InvoiceNo, ProductCode, Quantity, Discount, Subtotal )
CHAPTER 3: NORMALISATION
Database Systems

d) Third Normal Form (3NF)

Identify Transitive Dependencies

INVOICE (InvoiceNo, Date, CustomerNo, Name, Address, TelNo)

PRODUCT (ProductCode, ProductName, PriceUnit )

ORDER (InvoiceNo, ProductCode, Quantity, Discount, Subtotal )

Functional dependency

Relation Scheme in 3NF:

PRODUCT (ProductCode, ProductName, PriceUnit )

ORDER (InvoiceNo, ProductCode, Quantity, Discount, Subtotal )

INVOICE (InvoiceNo, Date, CustomerNo)

CUSTOMER (CustomerNo, Name, Address, TelNo)

Transitive dependency

47
CHAPTER 3: NORMALISATION
Database Systems

SUMMARY FOR CHAPTER 3 : NORMALIZATION

A two dimensional table with columns and rows is called a RELATION.

A relation scheme is a list of attributes and their corresponding domains.

Format for relation scheme :


Format : Relation Name ( Primary Key, Non Key Attribute)

2 problems in relational data model :


Anomalies
Information Redundancy

Anomalies is an errors or inconsistencies that may result when a user attempts to update a table
that contains redundant data.

Normalization is a process for assigning attributes into table and reduces data redundancy and
helps eliminate the anomalies problems.

3 level of normalization :
1 NF
2 NF
3 NF

1 NF is a relation where the intersection of each row and column contains no repeating values.

2 NF is a relation that is in 1 NF and every non-primary key attribute is fully functionally


depending on the primary key.

3 NF is a relation that is in 2 NF and is based on the concept of transitive dependency.

48
CHAPTER 3: NORMALISATION
Database Systems

SUMMARY FOR CHAPTER 3 : NORMALIZATION

Steps in normalization :

Functional dependency is a relationship between attributes in which one attributes or group of


attribute determines the value of another in the same table.

Transitive dependencies are a condition where an attribute is depend on another attribute that is
not part of the primary key.

49
CHAPTER 3: NORMALISATION
Database Systems

Table with repeating groups


(Unnormalised Form (UNF))
Remove repeating groups

First normal Form (1NF)

Identify Functional
Dependencies
Second Normal Form (2NF)

Remove Transitive
Third Normal Form (3NF) Dependencies

50

You might also like