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

2.3 Normalization

The document discusses normalization in database management systems. It defines normalization as organizing data to minimize redundancy and eliminate anomalies like insertion, update, and deletion anomalies. It describes three normal forms - 1NF, 2NF, and 3NF. 1NF requires attributes to be atomic and no multi-valued attributes. 2NF requires non-key attributes to depend on the whole primary key. Examples are provided to illustrate normalization concepts.

Uploaded by

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

2.3 Normalization

The document discusses normalization in database management systems. It defines normalization as organizing data to minimize redundancy and eliminate anomalies like insertion, update, and deletion anomalies. It describes three normal forms - 1NF, 2NF, and 3NF. 1NF requires attributes to be atomic and no multi-valued attributes. 2NF requires non-key attributes to depend on the whole primary key. Examples are provided to illustrate normalization concepts.

Uploaded by

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

Database Management System

By
Mr. Parag R. Sali
Lecturer
Department of Computer Technology
SNJB’s Shri. Hiralal Hastimal ( Jain Brothers)
Polytechnic, Chandwad
Program Name: Computer Engineering Group
Program Code : CO/CM/CW
Semester : Third
Course Title : Database Management System
Course Code : 22319

Normalization
NORMALIZATION
 Normalization concept
 Need of normalization

 Types of normalization
 1NF
 2NF
 3NF
 BCNF
NORMALIZATION
 Normalization is the process of organizing the data in
the database.
 Normalization is used to minimize the redundancy
from a relation or set of relations.
 It is also used to eliminate the undesirable
characteristics like Insertion, Update and Deletion
Anomalies.
 Normalization divides the larger table into the smaller
table and links them using relationship.
 The normal form is used to reduce redundancy from the
database table.
NEED OF NORMALIZATION
There are three types of anomalies that occur when the database is
not normalized.
 Insert Anomalies
 Delete Anomalies
 Update Anomalies

Let’s take an example to understand this anomalies.


Consider a Emp table having four attribute:
Emp_id,
Emp_name,
Emp_add,
Emp_dept.
EMPLOYEE TABLE
Emp_id Emp_name Emp_add Emp_dept NOT NULL

101 Nick Mumbai D870


101 Nick Mumbai D880
102 Mickey Pune D890
103 Rima Nasik D800
104 John Nagar D800
105 ABC Chandwad Insert Anomaly

Emp table Dept table

Emp_id Emp_nam Emp_add Emp_de


e pt Emp_dept Dept_nm
101 Nick Nasik D870,D8 D870 CM
80 D880 CE
102 Mickey Pune D890 D890 Ele.
103 Rima Nasik D800 D800 ME
104 John Nagar D800
Insert anomaly: Suppose a new employee joins the company, who is
under training and currently not assigned to any department then we
would not be able to insert the data into the table if emp_dept field doesn’t
allow nulls.

Delete anomaly: Suppose, if at a point of time the company closes the


department D890 then deleting the rows that are having emp_dept as
D890 would also delete the information of employee Micky since she is
assigned only to this department.

Update anomaly: In the above table we have two rows for employee Nick
as he belongs to two departments of the company. If we want to update the
address of Nick then we have to update the same in two rows or the data
will become inconsistent. If somehow, the correct address gets updated in
one department but not in other then as per the database, Nick would be
having two different addresses, which is not correct and would lead to
inconsistent data.
Example: To understand Anomalies

Student Table

R_no name age Br_id Br_nm HOD Mo_no


1 A 19 101 CM XYZ 1234
2 B 19 101 CM XYZ 1234
3 C 20 102 ME PQR 9976
4 D 20 101 CM XYZ 9876
Normalized Tables:

Student Table Branch Table

R_no name age Br_id Br_id Br_nm HOD Mo_no


1 A 19 101 101 CM XYZ 9876
2 B 19 101 102 ME PQR 9976
103 CE LMN 6487
4 D 20 101
TYPES OF NORMALIZATION

First Normal Form (1NF)


 A relation will be 1NF if it contains an atomic value.

 It states that an attribute of a table cannot hold


multiple values. It must hold only single-valued
attribute.
 First normal form disallows the multi-valued attribute,
composite attribute, and their combinations.
EmpTable

EMP_ID EMP_NAME EMP_PHONE EMP_STATE

14 John 7272826385, UP
9064738238
20 Harry 8574783832 Bihar
12 Sam 7390372389, Punjab
8589830302
Relation/Table Emp is not in 1NF because of multi-valued attribute EMP_PHONE.

The decomposition of the EMPLOYEE table into 1NF has been shown below:

EMP_ID EMP_NAME EMP_PHONE EMP_STATE

14 John 7272826385 UP
14 John 9064738238 UP
20 Harry 8574783832 Bihar
12 Sam 7390372389 Punjab
12 Sam 8589830302 Punjab
Student Table:

Stud_id stud_NAME Contact_no Addr

1 John 7272826385 UP
2 Harry 8574783832, Bihar
9876543223,
9823456789
3 Sam 7390372389, Punjab
8589830302
Normalized table into 1NF

Stud_id stud_NAME Contact_no Addr

1 John 7272826385 UP
2 Harry 8574783832 Bihar
2 Harry 9876543223 Bihar

2 Harry 9823456789 Bihar

3 Sam 7390372389, Punjab

3 Sam 8589830302 Punjab


Second Normal Form (2NF)
 In the 2NF, relational must be in 1NF.
 In the 2NF, all non-key attributes are fully functional dependent on the primary
key
 No non prime attribute is depend on the proper subset of any candidate key.
 Non prime: which is not a part of candidate key.
 Example: Let's assume, a collage can store the data of staff and the subjects they
teach. In a collage, a staff can teach more than one subject.
SATFF Table:
STAFF_ID SUBJECT STAFF_AGE

25 Chemistry 30
25 Biology 30
47 English 35
83 Math 38
83 Computer 38

In the above table, non-prime attribute STAFF_AGE is dependent on


STAFF_ID which is a proper subset of a candidate key. That's why it
violates the rule for 2NF.
Candidate key: { Staff_id , subject}
Primary key:{ staff_id}
Non –prime attribute:{staff_age}
To convert the given table into 2NF, we decompose it into two tables:

STAFF Table:
STAFF_SUBJECT Table:

Foreign key
Primary Key

STAFF_ID STAFF_AGE STAFF_ID SUBJECT

25 30 25 Chemistry

47 35 25 Biology

83 38 47 English
83 Math
83 Computer
Student table

Stud_id Stud_name Pro_id Pro_name

1 ABC p1 Lib mngt. sys


2 PQR p2 Bank Mngt sys
3 LMN p3 Clg mngt sys
4 XYZ p4 Hospital

Stud Table Project table

Stud_id Pro_id Pro_name


Stud_id Stud_n Pro_name
ame
1 p1 Lib mngt. sys
1 ABC Lib mngt. sys
2 p2 Bank Mngt sys
2 PQR Bank Mngt sys
3 LMN Clg mngt sys
3 p3 Clg mngt sys
4 XYZ Hospital
4 p4 Hospital
Third Normal Form (3NF)
 A relation will be in 3NF if –
 It is in 2NF and
 Not contain any transitive partial dependency.
 3NF is used to reduce the data duplication. It is also used to
achieve the data integrity.
 If there is no transitive dependency for non-prime attributes, then
the relation must be in third normal form.
 A relation is in third normal form if it holds at least one of the
following conditions for every non-trivial function dependency X →
Y.
 X is a super key.
 Y is a prime attribute, i.e., each element of Y is part of some
candidate key.
A B C non prime attribute
C -> B B->A C->A

Emp_details Table:

EMP_ID EMP_NAME EMP_ZIP EMP_STATE EMP_CITY

222 Harry 201010 UP Noida


333 Stephan 02228 US Boston
444 Lan 60007 US Chicago
555 Katharine 06389 UK Norwich
666 John 462007 MP Bhopal

we need to move the EMP_CITY and EMP_STATE to the new


<EMPLOYEE_ZIP> table, with EMP_ZIP as a Primary key.
Emp Table:

EMP_ID EMP_NAME EMP_ZIP

222 Harry 201010


333 Stephan 02228
444 Lan 60007
555 Katharine 06389
666 John 462007

Emp_zip Table:

EMP_ZIP EMP_STATE EMP_CITY

201010 UP Noida
02228 US Boston
60007 Noida Chicago
06389 UK Norwich
462007 MP Bhopal
Summary
Normal Form Description

1NF A relation is in 1NF if it contains an atomic value.

2NF A relation will be in 2NF if it is in 1NF and all non-key attributes are
fully functional dependent on the primary key.

3NF A relation will be in 3NF if it is in 2NF and no transition dependency


exists.

You might also like