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

Normalization

The document discusses the concept of normalization in database design, outlining its objectives to eliminate data redundancy and ensure logical data storage. It explains the different normal forms (1NF, 2NF, 3NF) and provides examples of how to convert tables into these forms. The lecture emphasizes the importance of achieving an anomaly-free and efficient database structure.

Uploaded by

Asad Raza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Normalization

The document discusses the concept of normalization in database design, outlining its objectives to eliminate data redundancy and ensure logical data storage. It explains the different normal forms (1NF, 2NF, 3NF) and provides examples of how to convert tables into these forms. The lecture emphasizes the importance of achieving an anomaly-free and efficient database structure.

Uploaded by

Asad Raza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

BSIT - 8th Morning

RECAP
MY NAME IS………..

I REMEMBER………
Normaliza
1NF
tion

Objective of
Today’s Lecture
2NF 3NF
Normalization
A step by step process to produce more efficient and
accurate database design.

Purpose is to produce an anomaly free design that is


smaller and well-structured.
Anomalies

Redundancy
❑An inconsistent,
incomplete or incorrect
state of database. Insertion

❑Four types of Deletion


anomalies are of
concern here. Updation
Goals of Normalization
Eliminate redundant data (for example, storing
the same data in more than one table).

Ensure data dependencies make sense (only


storing related data in a table).

Both of these are worthy goals as they reduce


the amount of space a database consumes, and
ensure that data is logically stored.
Normal Forms

First Normal Form

Second Normal Form

Third Normal Form

Boyce - Codd Normal Form

Higher Forms
Normalization Practice
Item Colors Price Tax

T-shirt Red, Blue 12.00 0.60

Polo Red, Yellow 12.00 0.60

T-shirt Red, Blue 12.00 0.60

Sweatshirt Blue, Black 25.00 1.25

Table is not in first normal form because:


• Multiple items in color field
• Duplicate records / no primary key *Price and Tax measure in $
First Normal Form
A relation is in first normal (1st NF) form if and only if

Every attribute is single valued for each tuple.

This means that each attribute in each row , or each cell


of the table, contains only one value.

No repeating fields or groups are allowed.


1NF
Item Colors Price Tax
T-shirt Red 12.00 0.60
T-shirt Blue 12.00 0.60
Polo Red 12.00 0.60
Polo Yellow 12.00 0.60
Sweatshirt Blue 25.00 1.25
Sweatshirt Black 25.00 1.25

Table is now in first normal form


Second Normal Form
A relation is in second normal form (2NF) if and only if

It is in first normal form (1st NF) and All the nonkey


attributes are fully functionally dependent on the key.

The only time, we have to be concerned about 2NF, when


the key is composite.

Removing the partial dependency


2NF – Conversion
Item Colors Price Tax
T-shirt Red 12.00 0.60
T-shirt Blue 12.00 0.60
Polo Red 12.00 0.60
Polo Yellow 12.00 0.60
Sweatshirt Blue 25.00 1.25
Sweatshirt Black 25.00 1.25

Table is not in second normal form because:


Price and tax depend on item, but not color
2NF
Item Colors
T-shirt Red
T-shirt Blue Item Price Tax
Polo Red T-shirt 12.00 0.60
Polo Yellow Polo 12.00 0.60
Sweatshirt Blue
Sweatshirt 25.00 1.25
Sweatshirt Black

Table is now in 2NF


Third Normal Form
A relation is in Third Normal Form (3rd NF) if and only if

It is in First (1st NF) and Second Normal Form (2nd NF) and
in which no non-primary-key attribute is dependent on
another non-key attribute.

All non-key attributes are functionally dependent only on


primary key.

Remove transitive dependency


3NF – Conversion
Item Colors
T-shirt Red
T-shirt Blue Item Price Tax
Polo Red T-shirt 12.00 0.60
Polo Yellow Polo 12.00 0.60
Sweatshirt Blue
Sweatshirt 25.00 1.25
Sweatshirt Black

Tables are not in third normal form because:


• tax depends on price, not item
3NF
Item Price
T-shirt 12.00
Item Colors
T-shirt Red Polo 12.00

T-shirt Blue Sweatshirt 25.00


Polo Red
Polo Yellow Price Tax
Sweatshirt Blue
12.00 0.60
Sweatshirt Black
25.00 1.25
Table is now in 3NF
Another Example
Normalization Practice
Student Student Society Society Supervi Supervi Position
ID Name ID Name sorID sor

111 Zofeen 001 EMS 123 ABC President


003 EC 124 XYZ Member

112 Rohaaf 001 EMS 123 ABC Member

113 Noshail 002 SS 123 ABC Member


005 AS 125 PQR President
008 NMS 126 LMK President
First Normal Form
A relation is in first normal (1st NF) form if and only if

Every attribute is single valued for each tuple.

This means that each attribute in each row , or each cell


of the table, contains only one value.

No repeating fields or groups are allowed.


Converting into 1NF
Studen Society Society Superv Superv Position
tID ID Name isorID isor
Student Student
ID Name 111 001 EMS 123 ABC President
111 Zofeen
111 003 EC 124 XYZ Member
112 Rohaaf
112 001 EMS 123 ABC Member
113 Noshail
113 002 SS 123 ABC President

113 005 AS 125 PQR President

113 008 NMS 126 LMK President


Second Normal Form
A relation is in second normal form (2NF) if and only if

It is in first normal form (1st NF) and All the nonkey


attributes are fully functionally dependent on the key.

The only time, we have to be concerned about 2NF, when


the key is composite.

Removing the partial dependency


Converting into 2NF
Student Student Society Society Superv Superv
ID Name ID Name isorID isor
111 Zofeen 001 EMS 123 ABC
112 Rohaaf
003 EC 124 XYZ
113 Noshail
001 EMS 123 ABC
StudentID SocietyID Position
002 SS 123 ABC
111 001 President
005 AS 125 PQR
111 003 Member 008 NMS 126 LMK
112 001 Member
113 002 President
113 005 President
113 008 President
Third Normal Form
A relation is in Third Normal Form (3rd NF) if and only if

It is in First (1st NF) and Second Normal Form (2nd NF) and
in which no non-primary-key attribute is dependent on
another non-key attribute.

All non-key attributes are functionally dependent only on


primary key.

Remove transitive dependency


Converting into 3NF
Student Student
Supervis Supervisor
ID Name Society Society Superv
orID
111 Zofeen ID Name isorID
123 ABC
001 EMS 123
112 Rohaaf 124 XYZ
113 Noshail 125 PQR 003 EC 124
126 LMK 001 EMS 123
002 SS 123
StudentID SocietyID Position
111 001 President 005 AS 125
008 NMS 126
111 003 Member
112 001 Member
113 002 President
113 005 President
113 008 President
Normalization Practice
More Normalization Practice

Students Home Normalization Practice at least 5


examples

Individual or group of students


CHHUTTI

AND THAT IS
FAREWELL TO
The DAY ☺

You might also like