You are on page 1of 17

Database

Management
System

By: Yasir Awan 1


Second Normal Form
 A relation is in 2nd normal form iff it is in the
first normal form and all non key attributes
are fully functionally dependent on key, that
is, there is no partial dependency

By: Yasir Awan 2


Second Normal Form

CLASS(crId, stId, stName, fId, room, grade)


crId, stId  stName, fId, room, grade
stId  stName crId  fId, room

By: Yasir Awan 3


Anomalies
 Redundancy
 Insertion Anomaly
 Deletion Anomaly
 Updation Aomaly

By: Yasir Awan 4


Anomalies

crId stId stName fId room grade


C3456 S1020 Suhail Dar F2345 104 B

C5678 S1020 Suhail Dar F4567 106

C3456 S1038 Shoaib Ali F2345 104 A

C5678 S1015 Tahira Ejaz F4567 106 B

By: Yasir Awan 5


Second Normal Form
Relation is decomposed based on the FDs
CLASS(crId, stId, stName, fId, room, grade)
crId, stId  stName, fId, room, grade
stId  stName crId  fId, room
STD(stId, stName)
COURSE(crId, fId, room)
CLASS(crId, stId, grade)

By: Yasir Awan 6


Second Normal Form

 Each of these tables is in second normal


form
 Free of anomalies due to partial
dependency

By: Yasir Awan 7


Third Normal Form
A table is in third normal form (3NF) iff it is
in 2NF and there is no transitive
dependency, that is, no non-key attribute
is dependent on another non-key attribute

By: Yasir Awan 8


Transitive Dependency

STD(stId, stName, stAdr, prName, prCrdts)


stId  stName, stAdr, prName, prCrdts
prName  prCrdts

By: Yasir Awan 9


Anomalies
stId stName stAdr prName prCrdts

S1020 Sohail Dar I-8 Islamabad MCS 64

S1038 Shoaib Ali G-6 Islamabad BCS 132

S1015 Tahira Ejaz L Rukh Wah MCS 64

S1018 Arif Zia E-8, Islamabad. BIT 134

By: Yasir Awan 10


Third Normal Form
 STD(stId, stName, stAdr, prName, prCrdts)
 stId  stName, stAdr, prName, prCrdts
 prName  prCrdts
 STD (stId, stName, stAdr, prName)
 PROGRAM (prName, prCrdts)

By: Yasir Awan 11


3NF Relations

 Each of the table is in 3NF


 Free of all anomalies

By: Yasir Awan 12


Boyce-Codd Normal Form
 A general form of 3NF
 Every relation in BCNF is in 3NF vice-versa
is not always true

By: Yasir Awan 13


BCNF
 Situation when table in 3NF is not in BCNF
 A non-key determines a part of the
composite primary key
 In other words, Each determinant must be
a key / candidate key.

By: Yasir Awan 14


BCNF
STUDENT_ADVISOR(SID, Major, Advisor, Maj_GPA)
SID, Major  Advisor, Maj_GPA
Advisor  Major
 Table is in 3NF, not in BCNF since the Advisor is not a candidate key

SID Major Advisor Maj_GPA


123 S/E Yasir 4.0
123 T/E Irfan 3.3
456 Literature Kamran 3.2
789 T/E Usman 3.7
678 S/E Yasir 3.5

By: Yasir Awan 15


Anomalies
 Suppose that in S/E the advisor Yasir is to be replaced by
Einstein. This change must be made in two (or more)
rows in the table. (Update anomaly)
 Suppose we want to insert a row with the information
that Bill Gates advises in Computer Science. This, of
course, cannot be done until at least one student
majoring in Computer Science is assigned Bill Gates as
and advisor. (Insertion Anomaly)
 Finally, if student number 789 withdraws from university,
we lose the information that Usman advises in T/E.
(Deletion Anomaly).

By: Yasir Awan 16


BCNF
 We decompose the table to bring it into
BCNF in the following way
 The determinant advisor becomes part of the
composite primary key. The attribute Major,
which is functionally dependent on Advisor,
becomes a nonkey attribute.
STUDENT (SID, Advisor , Maj_GPA)
ADVISOR (Advisor, Major)

By: Yasir Awan 17

You might also like