You are on page 1of 18

Database Systems and Applications

Lecture 15 Normalization

Normalization & Normal form


Normalization It is a tool to validate and improve t logical design, so that it satisfies certain conditions that avoid unnecessary duplication of data. It is based on the analysis of functional dependencies. Normal form It is a state of relation that results by applying simple rules regarding functional dependencies (or relationships between attributes) to that relation.

Normalization is often executed as a series of steps. Each step corresponds to a specific normal form that has known properties. As normalization proceeds, the relations become progressively more restricted in format, and also less vulnerable to update anomalies. For the relational data model, it is important to recognize that it is only first normal form (1NF) that is critical in creating relations. All the

Update Anomalies
Relations that have redundant data may have problems called update anomalies, which are classified as , Insertion anomalies Deletion anomalies Modification anomalies

Types of Normal forms


First normal form Second normal form Third normal form Boyce-Codd normal form Fourth normal form Fifth normal form

Steps in normalization
Table with multivalued attributes 1st normal form
Remove partial dependencies Remove multivalued attributes

2nd normal form

Remove transitive dependencies Remove remaining anomalies resulting from functional dependencies Remove multivalued dependencies Remove remaining anomalies

3rd normal form

Boyce-Codd normal form

4th normal form

5th normal form

Definition of 1NF
First Normal Form is a relation in which the intersection of each row and column contains one and only one value. There are two approaches to removing repeating groups from unnormalized tables: 1. Removes the repeating groups by entering appropriate data in the empty columns of rows containing the repeating data. 2. Removes the repeating group by placing the repeating data, along with a copy of the original key attribute(s), in a separate relation. A primary key is identified for the new relation.

First Normal Form (1NF)


A relation is in 1NF if it contains no multi valued attributes. Ex:
st_id name h_no r_no sem grade 2009P7PS001 Venu BH1 005 2 A 2 B 2009P7PS020 Amit 2 B 2 11 2 A A BH2 068 c_no year CSGC 210 2010-11 CSGC222 2010-11 CSGC210 2010-11 CSGC230 2010-11 EEGC245 2010-

1NF (cont.)
Ex:
st_id name sem grade
2009P7PS001 2 A 2009P7PS001 2 B 2009P7PS020 2 B 2009P7PS020 2 A 2009P7PS020

h_no r_no

c_no

year

Venu BH1 005 Venu BH1 005 Amit Amit Amit BH2 068 BH2 068 BH2 068

CSGC210 2010-11 CSGC222 2010-11 CSGC210 2010-11 CSGC230 2010-11 EEGC245 2010-11

Full functional dependency


Full functional dependency indicates that if A and B are attributes of a relation, B is fully functionally dependent on A if B is functionally dependent on A, but not on any proper subset of A. A functional dependency AB is partially dependent if there are some attributes that can be removed from A and the dependency still holds.

Second Normal Form (2NF)


A relation is in 2NF if it is in 1NF and every non key attribute is fully functionally dependent on the primary key. i.e., no non key attribute is functionally dependent on part (but not all) of the primary key.

2NF (cont.)
A relation that is in 1NF will be in 2NF if any one of the following conditions applies: The primary key consists of only one attribute (st_id in STUDENT1). No non key attributes exist in the relation (i.e., all the attributes are part of the primary key in the relation) Every non key attribute is functionally dependent on the full

Examples
STUDENT1

st_id

st_name h_no

r_no

address

STUDENT2 st_id c_no st_name h_no r_no address sem year grade

2NF (cont.)
The relation STUDENT2 is not in 2NF. The primary key in this relation is composite key st_id, c_no. In this the nonkey attributes name, h_no, r_no, address are functionally dependent on part of the primary key (st_id) but not on c_no.

2NF (contd.)
A partial functional dependency is a functional dependency in which one or more non key attributes are functionally dependent on part of the primary key. For example, in STUDENT2, the partial dependency creates redundancy. It leads to

2NF (cont.)
In this example the redundancy is the attributes name, h_no and r_no will appear in all the rows of the student has taken courses when there is change in h_no and/or r_no, we have to update it in more than one row depending upon the number of courses a student has taken. The anomaly may occur even

2NF (cont.)
So to convert a relation to 2NF, it is necessary to decompose the relation into new relations that satisfy one (or more) of the previously described conditions. Ex : We shall decompose the relation STUDENT2 into two relations. STUDENT1(st_id, name, h_no, r_no, adddress) ST_COURSE(st_id, c_no, sem, year, grade)

If a relation cant be converted to the second normal form, you risk data redundancy and difficulty in changing data. To convert first-normal-form tables to second-normal-form tables, remove columns that are not dependent on the primary key.

You might also like