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

Normal Forms

The document discusses database normalization and different normal forms. It defines normalization as a process to reduce data redundancy and improve data integrity. It explains 1st, 2nd, and 3rd normal forms as well as some common problems caused by lack of normalization like insertion, update, and deletion anomalies. Examples are provided to illustrate key concepts like functional dependencies and how decomposing tables can resolve issues like partial, transitive, and non-key dependencies.

Uploaded by

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

Normal Forms

The document discusses database normalization and different normal forms. It defines normalization as a process to reduce data redundancy and improve data integrity. It explains 1st, 2nd, and 3rd normal forms as well as some common problems caused by lack of normalization like insertion, update, and deletion anomalies. Examples are provided to illustrate key concepts like functional dependencies and how decomposing tables can resolve issues like partial, transitive, and non-key dependencies.

Uploaded by

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

NORMAL FORMS

Content

 Examples of tables in first normal forms.

 Tables in second and third normal forms.

 Problems of table in first normal form.


LEARNING OBJECTIVES

By the end, you should be able to:

Define the term normal form.

Explain 1st, 2nd and 3rd normal forms.


Definition of normal forms

Normal form is the process that deals with how to reduce


the amount of redundancy of data within a given table.

Normal form is a process that breaks up large tables into


smaller, more efficient tables.
Normalization of Database
 Database Normalization is a technique of organizing the data in the
database.

 Normalization is a systematic approach of decomposing tables to


eliminate data redundancy(repetition) and undesirable characteristics
like Insertion, Update and Deletion Anamolies.

 It is a multi-step process that puts data into tabular form, removing


duplicated data from the relation tables.
Normalization is used for mainly two
purposes
 Eliminating redundant (useless/unnecessary) data.

 Ensuring data dependencies make sense i.e data is logically


stored.
Mat.no Name Unit Hod Office_tel

401 Akon TCS Mr. X 53337

402 Bkon TCS Mr. X 53337

403 Ckon TCS Mr. X 53337

404 Dkon TCS Mr. X 53337

In the table above, we have data of 4 Computer Sci. students. As can be seen, data for
the fields Unit, Hod(Head of Department) and Office_tel is repeated for the students
who are in the same Unit in the college, this is Data Redundancy.
Problems Without Normalization
 Ifa table is not properly normalized and have data redundancy then it
will not only eat up extra memory space but will also make it difficult to
handle and update the database, without facing data loss.

 Insertion,Updation and Deletion Anomalies are very frequent if database


is not normalized.

 To understand these anomalies let us take an example of a Student table.


Deletion Anomaly

 In our Student table, two different information are kept together,


Student information and Department/unit information.

 Hence, at the end of the academic year, if student records are


deleted, we will also lose the branch information.

 This is Deletion anomaly.


Updation Anomaly
 What if Mr. X leaves the college? Or is no longer the HOD
of computer science department?

 In that case all the student records will have to be updated,


and if by mistake we miss any record, it will lead to data
inconsistency.

 This is Updation anomaly.


Insertion Anomaly
 Suppose for a new admission, until and unless a student opts for a unit,
data of the student cannot be inserted, or else we will have to set the
branch information as NULL.

 Also, if we have to insert data of 100 students of same unit, then the unit
information will be repeated for all those 100 students.

 These scenarios are nothing but Insertion anomalies.


Normalization Rule
Normalization rules are divided into the following normal forms: with these rules we make our table.
 First Normal Form (1NF)

 Second Normal Form (2NF)

 Third Normal Form (3NF)

 Boyce and Codd Normal Form (BCNF)

 Fourth Normal Form


Bear in mind that a table cannot be normalized beyond its Highest Normal Form (HNF)
First Normal Form (1NF)
For a table to be in the First Normal Form, it should follow the following 4
rules:
 It should only have single(atomic) valued attributes/columns.

 Values stored in a column should be of the same domain

 All the columns in a table should have unique names.

 And the order in which data is stored, does not matter.


First normal form  deals with the "shape" of a record type
First Normal Form (1NF)
Mat.no Name Unit Hod Office_tel Office_tel

401 Akon TCS Mr. X 45778 53337

402 Bkon TCS Mr. X 45778 53337

403 Ckon TCS Mr. X 45778 53337

404 Dkon TCS Mr. X 45778 53337


Second Normal Form (2NF)

For a table to be in the Second Normal Form,

 It should be in the First Normal form.

 And, it should not have Partial Dependency.


Partial Functional Dependency
 A PartialFunctional Dependency is when you have a Composite
Primary Key (a primary key that is made up of multiple columns),
and one of the non-key columns is functionally dependent on one,
but not all of the columns that make up the Composite Primary
Key.
 To resolve partial functional dependencies, you would create
a parent table, and place the column(s) that are partially
functionally dependent in the parent table.
 The primary key of the parent table is the column that the
column(s) are functionally dependent on.
Student table

Student_id Name Reg_no Branch address


Score table
Score_id Student_id Subject_id Marks teacher

1 10 1 82 Mr. J

2 10 2 77 Mr. C++

3 11 1 85 Mr. J

4 11 3 82 Mr. C#

5 11 4 95 Mr. P
To remove partial dependency, we create another table,
subject table.
Score_id Student_id Subject_id Marks
1 10 1 82
2 10 2 77
3 11 1 85
4 11 3 82
5 11 4 95

Subject_id Subject_name Teacher

1 Java Mr. J
2 C++ Mr. C++

3 C# Mr. C#
4 Php Mr. P
Third Normal Form (3NF)

A table is said to be in the Third Normal Form when,

 It is in the Second Normal form.

 And, it doesn't have Transitive Dependency.


Transitive Dependency
 A Transitive Dependency is when you have a column that is functionally
dependent on a column that is not the primary key.
 For example, when column C is functionally dependent on column B, and
column B is functionally dependent on column A, and column A is the
primary key.
 To resolve transitive dependencies, you need to create another table and
place the columns that are transitively dependent in the new table. This
new table is often a child table. The primary key of the new table is the
column that the columns are functionally dependent on in the original
table
Updated score table

Score_id Student_id Subject_id Marks Exam_name Total_marks

All other column depend on the composite


primary key except total marks. Total
marks only depends on exam name.
The solution to this problem is to put the exam_name
and total_marks on another table. we will call this
table child table.
Exam_name Total_marks

Exam table
Boyce and Codd Normal Form (BCNF)

 Boyce and Codd Normal Form is a higher version of the Third Normal
form. This form deals with certain type of anomaly that is not handled
by 3NF. A 3NF table which does not have multiple overlapping
candidate keys is said to be in BCNF. For a table to be in BCNF,
following conditions must be satisfied:
BCNF

A table is said to be in the boyce and codd Normal Form when,

 It is in the third Normal form.

 And, for any dependency A B, A should be a super key.


 A cannot be a prime attribute, with b being a prime attribute
College enrollment table

Student_id Subject professor


101 Java p.Java
101 C++ p.Cpp
102 Java p.java2
103 C# p.Chash
104 Java p.java

If you look closely professor can lead us to subject and subject


is a part of the primary key. i.e subject is a prime attribute and
professor is a prime attribute. There is a dependency here,
subject is dependent on professor but professor is not a super
key.
Our table doesn’t satisfy BCNF, so we
have to break the table.
Student_id P_id P_id Professor student

Student table Professor table

You might also like