Professional Documents
Culture Documents
Lecture 15 Normalization
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
Steps in normalization
Table with multivalued attributes 1st normal form
Remove partial dependencies Remove multivalued attributes
Remove transitive dependencies Remove remaining anomalies resulting from functional dependencies Remove multivalued dependencies Remove remaining anomalies
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.
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
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.