0% found this document useful (0 votes)
5 views32 pages

DB12 Normalization

Normalization

Uploaded by

HAMXALA KHAN
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 views32 pages

DB12 Normalization

Normalization

Uploaded by

HAMXALA KHAN
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/ 32

Introduction to

Database Systems

1
Normalization
Chapter - 14

2
▪ Database normalization is the
process of organizing the fields and
tables of a relational database to
minimize redundancy.
Normalization ▪ Normalization usually involves
dividing large tables into smaller
(and less redundant) tables and
defining relationships between
them.
▪ The objective is to separate data so
that additions, deletions, and
modifications of a field can be made
in just one table and then
Normalization propagated through the rest of the
database using the defined
relationships.
▪ Normalized design makes the
maintenance of database easier.
User View

Unnormalized
Relationship
Remove repeating groups
Normalization Normalized
Relations (1NF)
Remove partial dependencies
Second Normal Form
Relations (2NF)
Remove transitive dependencies
Third Normal Form
Relations (1NF)
Chapter 17 Designing Databases 17-6
▪ A state of DB that can lead the
DB to inconsistency or incorrect
state of database
Anomalies
▪ Three types of anomalies are of
concern here which occur due to
Redundancy, insertion, deletion
and updation
SID SNAME CID Subject FID FName
101 Ahmed C1 Math F1 Ali
102 Waqas C1 Math F1 Ali
103 Aslam C2 English F2 Ayan
104 Farooq C2 English F2 Ayan

Insertion 105 Rafia C3 Physics F3 Arman


106 Waqas C3 Physics F3 Arman
Anomaly 107 Aslam C2 English F2 Ayan
108 Waqas C1 Math F1 Ali
if university offer a new course, for example
physics then what we written in place of SID
Sname etc.
SID SNAME CID Subject FID FName
101 Ahmed C1 Math F1 Ali
102 Waqas C1 Math F1 Ali
103 Aslam C2 English F2 Ayan
104 Farooq C2 English F2 Ayan

Updation 105 Rafia C3 Physics F3 Arman


106 Waqas C3 Physics F3 Arman
Anomaly 107 Aslam C2 English F2 Ayan
108 Waqas C1 Math F1 Ali
To update the name of a subject who occurs
twice or more than twice in a table, we will have
to update Subject Name column in all the rows,
else data will become inconsistent.
SID SNAME CID Subject FID FName
101 Ahmed C1 Math F1 Ali
102 Waqas C1 Math F1 Ali
103 Aslam C2 English F2 Ayan
104 Farooq C2 English F2 Ayan

Deletion 105 Rafia C3 Physics F3 Arman


106 Waqas C3 Physics F3 Arman
Anomaly 107 Aslam C2 English F2 Ayan
108 Waqas C1 Math F1 Ali
If Faculty id F1 leave the university for deleting
that faculty record the entire row will be
effected and the , entire student record will be
deleted along with it.
▪ Different forms or levels of
normalization
▪ Called first, second, third,
fourth, fifth forms
Normalization ▪ Each form has got certain
conditions
▪ If a table fulfils the condition(s)
for a normal form then the table
is in that normal form
▪Remove any repeating groups
▪All repeating groups are moved
into a new table
▪Foreign keys are used to link the
1 NF tables
First ▪When a relation contains no
Normal repeating groups, it is in the first
Form normal form
▪Keys must be included to link the
relations, tables
1 NF
First
Normal
Form
▪ If A and B are attributes of relation R, B is
functionally dependent on A
▪ (denoted A→ B),
▪ if each value of A in R is associated with
exactly one value of B in R.
Functional ▪ Example:
dependency ID Name
S1 Meier
S2 Weber

The attribute Name is functionally


dependent of attribute ID (ID → Name).
▪ArtistName→BirthYear

• Aslam was born in 1881

Functional ▪Author, Title→PublDate


dependency
• Farhans’s ‘computer’ was published in
1979
▪ A database is in second normal form if it
2 NF satisfies the following conditions:
Second ▪ It is in first normal form
Normal ▪ All non-key attributes are fully
functional dependent on the primary
Form key
Customer_id Store_ID Location
1 1 Karachi
1 3 Islamabad

2 NF 2
3
1
2
Karachi
Rawalpindi
Second 4 3 Islamabad

Normal Customer_id Store_ID


Store_ID Location
Form 1 1
1 Karachi
Example 1 3
2 Rawalpindi
2 1
3 Islamabad
3 2
4 3
▪ By transitive functional dependency,
we mean we have the following
Transitive relationships in the table:
Functional
▪ A is functionally dependent on B,
Dependency and B is functionally dependent on C.
In this case, C is transitively
dependent on A via B.
▪ It is in second normal form
▪ There is no transitive functional
dependency

3 NF stId stName stAdr prName prCrdts


Third S1020 Sohail Dar I-8 Islamabad MCS 64

Normal S1038 Shoaib Ali G-6 Islamabad BCS 132


Form S1015 Tahira Ejaz L Rukh Wah MCS 64

S1018 Arif Zia E-8, BIT 134


Islamabad.
prName prCrdts
MCS 68

BCS 132

BIT 134

3 NF
Third stId stName stAdr prName
Normal
S1020 Sohail Dar I-8 Islamabad MCS
Form
S1038 Shoaib Ali G-6 Islamabad BCS

S1015 Tahira Ejaz L Rukh Wah MCS

S1018 Arif Zia E-8, Islamabad. BIT


▪BCNF is the advance version of
3NF. It is stricter than 3NF.
Boyce- ▪A table is in BCNF if every
Codd
Normal functional dependency X →Y, X is
Form the super key of the table.
▪For BCNF, the table should be in
3NF, and for every FD, is super key
Branch_Num Stu_Course_
Stu_ID Stu_Branch Stu_Course
ber No

Computer
101 Science & DBMS B_001 201
Engineering

Computer
Computer
101 Science & B_001 202
Networks
Engineering

Electronics &
VLSI
102 Communicatio B_003 401
Technology
n Engineering

Electronics & Mobile


102 Communicatio Communicatio B_003 402
n Engineering n
Functional Dependency of the above is as
mentioned:
▪ Stu_ID −> Stu_Branch
▪ Stu_Course −> {Branch_Number,
Stu_Course_No}
▪ Candidate Keys of the above table are: {Stu_ID,
Stu_Course}
Why this Table is Not in BCNF?
▪ The table present above is not in BCNF, because
as we can see that neither Stu_ID nor
Stu_Course is a Super Key.
▪ As the rules mentioned above clearly tell that
for a table to be in BCNF, it must follow the
property that for functional dependency X−>Y, X
must be in Super Key and here this property
fails, that’s why this table is not in BCNF.
▪After BCNF fourth, fifth and domain-
key normal forms exist
Higher ▪4NF deals with multivalued
dependency, fifth deals with possible
forms lossless decompositions, DKNF
reduces further chances of any
possible inconsistency
Example 1

27
1NF
2NF
3NF
31
Thank You

32

You might also like