You are on page 1of 7

Normalization.

The process of producing a simpler and more reliable database structure or relations is called normalization. It is used
to create a suitable set of relation for storing data. This process works through different stages known as normal forms. These
stages are INF, 2NF, 3NF, BCNF, 4NF and 5NF.

The purpose of normalization is to remove anomalies from the data. Each normal form has certain requirements or
condition. These conditions have to fulfill to bring the database in that particular normal form. If a relation satisfies the
conditions of a normal form, it is said to be in that normal form.

Anomalies.

Anomalies are undesirable properties or problems in relation that exist due to data redundancy in relation.
Anomalies affect the process of inserting, deleting and modifying data in relations.

Types of anomalies.

Different types of database anomalies are as follows:

Insertion Anomaly.

Insertion anomaly occurs when a new record is inserted in the relation. In this anomaly, the user cannot insert a fact
about an entity until he has an additional fact about another entity.

Deletion Anomaly.

Deletion anomaly occurs when a record is deleted from the relation. In this anomaly, the deletion of facts about an
entity automatically deletes the fact of another entity.

Modification Anomaly.

The modification anomaly occurs when the record is updated in the relation. In this anomaly, the modification in the
value of specific attribute requires modification in all records in which that value occurs.

First Normal Form

A relation is in first normal form 1NF if it does not contain a repeating group. A repeating group is a set of one or
more data items that may occur a variable number of times in a cell. The value in each cell should be atomic that is each cell in a
table should contain only one value.

Teacher Table

Student_ID Subject_ID NAME AGE Subject Credit Marks Teacher_ID Teacher_


Name Hour Name
1 1 Ali 42 SE 4 78 001 Naveed

2 English 2 56 002 Adila

3 Statistics 4 42 003 Mughal


2 4 Hina 30 IAP 4 99 004 Salman

2 English 2 87 002 Adila


3 5 Umair 34 DB 2 33 005 Zeeshan
First Normal Form

Student_ID Subject_ID NAME AGE Subject Credit Marks Teacher_ID Teacher_


Name Hour Name
1 1 Ali 42 SE 4 78 001 Naveed
1 2 Ali 42 English 2 56 002 Adila
1 3 Ali 42 Statistics 4 42 003 Mughal
2 4 Hina 30 IAP 4 99 004 Salman
2 2 Hina 30 English 2 87 002 Adila
3 5 Umair 34 DB 2 33 005 Zeeshan

Problem in First Normal Form.

Updating Problem (updating anomaly)

Addition Problem (Addition anomaly)

Deletion Problem (Deletion Anomaly)

Second Normal Form

A relation is in second normal form 2NF if it is in INF and if all its non key attributes are fully functionally dependent
on the whole primary key. If any non key attribute is not functionally dependent on whole primary key or only dependent on a
portion of primary then it is partial functional dependency. In 2NF we have to remove partial functional dependency from the
table to achieve full functional dependency. For example, Marks is fully dependent on Student_ID and Subject_ID.

Student_ID, Subject_ID Marks

Second Normal Form

Student_ID NAME AGE


1 Ali 42
2 Hina 30
3 Umair 34

Subject_ID Subject Name Credit Hour Teacher_ID Teacher_ Name


1 SE 4 001 Naveed
2 English 2 002 Adila
3 Statistics 4 003 Mughal
4 IAP 4 004 Salman
5 DB 2 005 Zeeshan

Student_ID Subject_ID Marks


1 1 78
1 2 56
1 3 42
2 4 99
2 2 87
3 5 33

Third Normal Form

A relation is in third normal form if it is in 2NF and if no non-key attribute is dependent on another non-key attribute.
That is there should not be any transitive dependency. Transitive dependency occurs when a non-key attribute depends on
another non-key attribute instead of depending on the primary key. Or in other words transitive dependency occurs when a
non-key attribute which depends on primary key determines another non-key attribute.

For example Teacher_ID dependent on Subject_ID and Teacher_Name is dependent on Teacher_ID.

Subject_ID Teacher_ID

Teacher _ID Teacher _Name

So, Teacher_Name is transitive dependent on Subject_ID.

Subject_ID Teacher_ID, Teacher _ID Teacher _Name

Transitive Dependency.

Student_ID NAME AGE


1 Ali 42
2 Hina 30
3 Umair 34

Subject_ID Subject Name Credit Hour Teacher_ID


1 SE 4 001
2 English 2 002
3 Statistics 4 003
4 IAP 4 004
5 DB 2 005

Teacher_ID Teacher_ Name

001 Naveed
002 Adila
003 Mughal
004 Salman
005 Zeeshan

Student_ID Subject_ID Marks


1 1 78
1 2 56
1 3 42
2 4 99
2 2 87
3 5 33
Practice # 1:

Employee # Designation Designation Proficiency Employee Employee Department Deptt Department


# Type # Name Age # City Head
1 111 DBA 3 John 42 78 ISB Lara

179 SE 5

203 NA 6

2 203 NA 5 Strauss 41 99 LAH Macdonald

111 DBA 1
3 179 SE 3 Pointing 22 33 GUJ Ibraham

Practice # 2:

Accountant Skill# Skill Proficiency # Accountant Accountant Group Group Group


# Category Name Age Number City Supervisor

1 111 System 3 Ali 42 78 ISB Naveed

179 TAX 5

203 AUDIT 6

2 179 TAX 5 Daud 41 99 LAH Salman

204 CONSULTING 1
3 111 System 3 Zahid 22 33 GUJ Zeeshan

Practice # 3:

Student ID Student Name Society ID Society Name Position Supervisor ID Supervisor


Name

123 Masood 002 English Member 1 Waseem

005 Physics Chairman 3 Liaqat

008 Biology Member 4 Yasmeen

132 Khalida 001 Urdu Chairman 1 Waseem

003 Math Member 2 Chaudhary

142 Javed 001 Urdu Member 1 Waseem


Practice # 4:

Parent ID Parent Name Child ID Child Name

1 Masood 002 Ali

005 Umer

008 Imran

2 Khalida 001 Asif

003 Iqra

3 Javed 004 Anum

Parent ID Parent Name

1 Masood

2 Khalida

3 Javed

Parent ID Child ID Child Name

1 002 Ali

1 005 Umer

1 008 Imran

2 001 Asif

2 003 Iqra

3 004 Anum

Practice # 5:

Employee ID Employee Name City ID City Name


1 Naveed 002 Gujranwala
2 Zain 001 Lahore
3 Farrah 004 Islamabad
4 Umer 002 Gujranwala

Practice # 6:

Draw normalized relations and their relationship between following entities

 Country
 State
 City
Practice # 7:

Draw normalized relations and their relationship between following entities

 Student
 Subject
 Teacher

NOTE: A subject is only taught by one teacher but a teacher can teach many subject. A student can read only one
subject but one subject can be read by many students.

Country_ID Country_NAME
1 Pakistan
2 India
3 America

State_ID State_NAME Country_ID


1 Punjab 1
2 Rajistan 2
3 Sindh 1

City_ID City_NAME State_ID


1 Lahore 1
2 Karachi 3
3 Sailkot 1
Student_ID Student_NAME Subject_ID
1 GR 1
2 CR 2
3 ABC 1

Subject_ID Subject_NAME
1 DBA
2 ENGLISH
3 MATH

Teacher_ID Teacher_NAME
1 ZEESHAN
2 ADILA
3 NAVEED

Subject_Teacher Table

Teacher_FID Subject_FID
1 1
1 2
1 3
2 1
2 3
3 2

You might also like