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

Normalization: Background Knowledge

The document discusses normalization in databases. It explains the concepts of anomalies, normal forms including 1NF, 2NF and 3NF. Examples are given to show how to convert relations to these normal forms by removing anomalies and dependencies.

Uploaded by

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

Normalization: Background Knowledge

The document discusses normalization in databases. It explains the concepts of anomalies, normal forms including 1NF, 2NF and 3NF. Examples are given to show how to convert relations to these normal forms by removing anomalies and dependencies.

Uploaded by

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

Normalization

Background Knowledge

- Well Structured Relation


A relation is said to be a well structured relation if it doesn’t have any anomaly.

o Anomaly
It is an inconsistency that may arise when a user tries to insert data (insertion
anomaly) or tries to modify data (modification / updation anomaly) or tries to
delete data (deletion anomaly).
Student
R# Name C-Code C-Title

1 Faisal Cs-241 DBMS

1 Faisal Cs-342 OS

2 Imran Cs-342 OS

4 Ahsan Cs-312 DLD

5 Ali

 Insertion Anomaly
We can’t insert data of a student unless he registers some course, or vice
versa.

 Modification / Updation Anomaly


If we want to change the name of Faisa, R#-1, from Faisal to Muhammad
Faisal, then we have to make this change for multiple times, as it occurs
more than one times in the Student Data Base.

 Deletion Anomaly
If we want to delete student data R#-4, Ahsan, we also lose data about
the course Cs-312, DLD.
DBMS

www.bscs15.tk www.leemedia.tk www.ttdate.tk


Normalization
It is a step by step process in which we convert a complex data structure (relation with
anomalies) into a well structured relation (Relation without anomalies).

- Normal Form
It is the state or form of a relation that arises when we apply some rules of
normalization on that relation, for example First Normal Form or 1NF, 2NF etc.

o 1NF
A relation is said to be in 1NF if it doesn’t have any repeating group.

Problem
R# Name C-Code C-Title

1 Faisal Cs-241 DBMS

1 Faisal Cs-342 OS

2 Imran Cs-342 OS

4 Ahsan Cs-312 DLD

This table contains repeating group, so it’s not in 1NF


Solution
We make a composite primary key by combining some attributes from the
repeating group, to remove the repeating group.
R# Name C-Code C-Title

1 Faisal Cs-241 DBMS

1 Faisal Cs-342 OS

2 Imran Cs-342 OS

4 Ahsan Cs-312 DLD

Now it’s in 1NF.


DBMS

www.bscs15.tk www.leemedia.tk www.ttdate.tk


o 2NF
A relation is said to be 2NF if it is in 1NF, and there is no partial functional
dependency in it.

 Functional Dependency
If we have a relation
R (A1, A2, A3, A4, A5)
Student (R#, name, C-Code, C-Title)

If A1 determines A2, A3, A4, A5 then we say that A2, A3, A4, A5 are
functionally dependent upon A1.

 Partial Functional Dependency


If we have a relation;
R (A1, A2, A3, A4, A5)

R# Name C-Code C-Title Grade

1 Faisal Cs-241 DBMS A

1 Faisal Cs-342 OS A

2 Imran Cs-342 OS A

4 Ahsan Cs-312 DLD A

If part of a composite primary key determines some non-key attributes


then this phenomenon is known as partial functional dependency.

A1  A2 partially functional dependent


A3  A4 partially functional dependent
 A5 Fully functional dependent
DBMS

www.bscs15.tk www.leemedia.tk www.ttdate.tk


Solution

R# Name R# C-Code Grade C-Code C-Title

1 Faisal 1 Cs-241 A Cs-241 DBMS

1 Faisal 1 Cs-342 A Cs-342 OS

2 Imran 2 Cs-342 A Cs-342 OS

4 Ahsan 4 Cs-312 A Cs-312 DLD


DBMS

www.bscs15.tk www.leemedia.tk www.ttdate.tk


o 3NF
A relation is said to be in 3NF if it is in 2NF and there is no transitive dependency
in it.
 Transitive Dependency
If a non-key attribute determines another non-key attribute, then this
phenomenon is known as transitive dependency.

For example
R (A, B, C, D, E)
And in this relation AB, C, D, E but CE as well.

C-no C-name SP-ID SP-Name Region

C1 Waleed SP-3 Ali G-10

C2 Waleed SP-4 Ahmed G-10

C3 Ali SP-7 Naeem G-8

C4 Ahsan SP-3 Ali G-10

C5 Yahya SP-9 Ali I-9

C6 Waleed Sp-13 Ahmed F-10

C-no C-name, SP-ID, SP-Name, Region

 Hints
1. Customer can be served by only one sales person, while a sales
person can serve many customers.
2. One sales person belongs to only one region, while a region can
have many sales persons.
DBMS

www.bscs15.tk www.leemedia.tk www.ttdate.tk


Solution

C-no C-name SP-ID SP-ID SP-Name Region

C1 Waleed SP-3 SP-3 Ali G-10

C2 Waleed SP-4 SP-4 Ahmed G-10

C3 Ali SP-7 SP-7 Naeem G-8

C4 Ahsan SP-3 SP-3 Ali G-10

C5 Yahya SP-9 SP-9 Ali I-9

C6 Waleed Sp-13 Sp-13 Ahmed F-10


DBMS

www.bscs15.tk www.leemedia.tk www.ttdate.tk

You might also like