0% found this document useful (0 votes)
2 views

Normalization

Uploaded by

budhah282
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Normalization

Uploaded by

budhah282
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

BIT 6113

Database Management
System
Sushil Bhattarai
[email protected]
Normalization
• Main objective is to organize data in tables
• Helps maintain relations between tables
• One value should be at only one place
• Break down the data in smaller sizes
• See the following example of a table “Student” with following data
Name Address Subject Instructor
Ram Koteshwor Programming, Database Hari, Krishna
Shyam Baneshwor Database Krishna

Here, the Instructor is stored in multiple places. If the name of one of the
Instructors need to be changed, the data in multiple places needs to be changed.
If one of the students (say Shyam Prashad) decides to study a new subject, 2
columns (Subject and Instructor) need to be updated. The name of each of the
subject and Instructor appears multiple times in the table.
• Normal Forms:
1. 1 NF
2. 2 NF
3. 3 NF

1NF Rule
 Each table cell should contain a single value
 Each row must be unique.
 The above table can be redesigned using 1NF as
Name Address Subject Instructor
Ram Koteshwor Programming Hari
Ram Koteshwor Database Krishna
Shyam Baneshwor Database Krishna

• Each cell now contains single value but still the data is repeated.
2NF rule

• Table should be in 1NF


• Single Column Primary Key
• The table can now be redesigned into Student and Subject tables as

Primary Key of Student


Table is now called
Foreign Key in Subject
Table
Primary Key for
Student Table

Subject
Student
StudentId Subject Instructor
Id Name Address
1 Programming Hari
1 Ram Koteshwor
1 Database Krishna
2 Shyam Baneshwor
2 Database Krishna
3NF rule
• Table should be in 2NF
• There should not be any transitive dependencies
Primary Key for
Student Table Primary Key for
Instructor Table
Student
Instructor
Id Name Address
Id Instructor
1 Ram Koteshwor
1 Hari
2 Shyam Baneshwor
2 Krishna
Primary Key for
Subject Table
All Columns are
dependent on Primary
Subject Key
Id Subject
1 Programming
2 Database
Detail
StudentId SubjectId InstructorId
1 1 1
1 2 2
2 2 2
Example of Normalization
• Consider the following data of different projects that has to be stored in a
table

Project Employee Department Project Time

Assets, Mutual
Fund,
Ram Finance 4.5, 3, 7
Profitability
Analysis

Krishna R&D Java, C++ 8, 9

Break down the above data into appropriate tables using the 1,2 and 3 Normal Forms.

1NF
Project

Employee Department Project Time


Ram Finance Assets 4.5
Ram Finance Mutual Fund 3
Ram Finance Profitability Analysis 7
Krishna R&D Java 8
Krishna R&D C++ 9
2NF
Employee
ID Employee Department
1 Ram Finance
2 Krishna R&D

Details

EmployeeID Project Time


1 Assets 4.5
1 Mutual Fund 3
1 Profitability Analysis 7
2 Java 8
2 C++ 9
3NF
Employee

ID Employee DepartmentID
1 Ram 1 Department
2 Krishna 2
DepartmentID Department
1 Finance
2 R&D

Details
Project
EmployeeID ProjectID Time
ID Project
1 1 4.5
1 Assets 1 2 3
2 Mutual Fund 1 3 7
3 Profitability Analysis
2 4 8
4 Java 2 5 9
5 C++
Assignment of Normalization
• Consider the following data that has to be stored in a table
Name Salary Department Department_head Department_Location
ram, shyam, hari,krishna 8000, 1000, 9000,8000 IT Krishna Pokhara
kripa, sujan 8000, 9000 HR sujan kathmandu

Break down the above data into tables using 1NF, 2NF and 3NF.
 The above data can be represented in 1NF as

Details

Name Salary DepartName DepartmentHead DepartmentLocation

Ram 8000 IT Krishna Pokhara

Shyam 10000 IT Krishna Pokhara

Hari 9000 IT Sujan Kathmandu

Kripa 8000 HR Sujan Kathmandu

Krishna 8000 IT Krishna Pokhara

Sujan 9000 HR Sujan Kathmandu


The above data can be represented in 2NF as
Details
Department Name Salary DepartmentId
ID DepartName DepartmentHead DepartmentLocation Ram 8000 1
1 IT Krishna Pokhara Shyam 10000 1
2 HR Sujan Kathmandu Hari 9000 2
Kripa 8000 2
Krishna 8000 1
Sujan 9000 2

The above data can be represented using 3NF as


Department
Id Department Details
1 IT Id Name Salary DepartmentId
2 HR 1 Ram 8000 1
2 Shyam 10000 1
3 Hari 9000 2
DepartmentDetails 4 Kripa 8000 2
Id DepartmentId DepartmentHeadID location 5 Krishna 8000 1
6 Sujan 9000 2
1 1 5 Pokhara
2 2 6 Kathmandu

You might also like