Second Normal Form
Second Normal Form
Although the figure only shows four attributes, we can generalize this procedure for any
relation that we need to transform to 2NF if we assume that C stands for the collection
of attributes that are fully dependent on the key and D stands for the collection of
attributes that are partially dependent on the key. In our case study A stands for
Course_Code and B for Rollno. Total_Hrs acts as C and (Name, System_Used,
Hourly_Rate) acts as D which depends on Rollno; (Course_Name, Teacher_Name)
also acts as D which depends on only Course_Code.
Example
1 Transformation of STUDENT (Course_Code, Course_Name, Teacher_Name, RoIIno,
2 Name, System_Used Hourly_Used, Total-Hours) into a 2NF
The above rule calls for breaking this relation into three new relations. The primary key
of STUDENT (Course Code, Rollno) and the remaining attributes of this relation that
fully depends on this composite key is Total_Hours. The scheme of this new relation
that we have named HOURS ASSIGNED is as follows:
1 HOURS_ASSIGNED (Course_Code, Rollno, Total_Hours)
The second relation contains Rollno as its primary key, because Rollno fully determine
the Name, System_Used, and Hourly_Rate. The scheme of this relation is as follows:
1 STUDENT_SYSTEM_CHARGE (Rollno, Name, System_Used, Hourly_Rate)
The third relation contains Course_Code as its primary key, because Course_Code
fully determine the Course_Name, Teacher_Name. The scheme of this relation is as
follows:
1 COURSE (Course Code, Course_Name, Teacher_Name)
Use of 2NF to remove anomalies of First Normal form
Insert Anomalies
It is now possible to insert the information about the student who does not join any
course e.g. we can store the information about the RoIIno 110 who not join any course
in STUDENT _SYSTEM_CHARGE database as shown above. Similarly now we are
able to store the information about the course which has no enrolled student 0.g we
can store that CI course is of Visual Basic in COURSE database. It does not matter
that whether it has an enrolled student or not.
Update Anomalies
In the revised structure, it is possible to change the teacher for a particular course in
the COURSE database through a single modification.
Delete Anomalies
In the revised structure, we can delete the information of student having Rollno 109
without losing the information about his course i.e. C4
Data Anomalies in 2NF Relations
Relations in 2NF are still subject to data anomalies. For sake of explanation, let us
assume that the system on which a student works functionally determines the hourly
rate charged from the student. That is, System_Used ~ Hourly_Rate. This fact was not
considered in the explanation of the previous normal form but it is not an unrealistic
situation. If this functional dependence exists then the following anomalies will occur:
Insertion anomalies
The solution of all above anomalies is provided by the third normal form, which deals
with the problem of transitive dependence.
Practice Session:
Consider the relation scheme and FD shown below. What is the highest normal form of
this relation? Transform this relation to its next higher form. Can the information of the
given relation be recovered? What operation is necessary to recover it?
1 Programmer-Task (Programme- ID, Programming-Package-ID,Programming-Package-Name,
2 Total-Hours- Worked-on-Package). Programming-Package-ID, Programming-Package-Name
The highest form of this relation is INF because there are partial dependence on the
composite key. Consider for example, Programming-Package-ID Programming-
Package- Name.
The next highest form of this relation is to 2NF. To transform it we can use Figure as a
guide. According to this figure, we need to create two new relations. The first relation
has as its key the primary key of the given relation: Programmer-ID, Programming
Package- ID the scheme of this first relation is.
1 Programmer-Activity (Programmer-ID, Programmer-Package-ID, Total-Hours- Worked-on- Pac
The second relation has as its primary key the attribute: Programming-Package-ID.
‘The scheme of this relation is:
1 Package-Info (Programming-Package-ID, Programming-Package-Name)
The information of the original relation can be recovered by means of a join operation
on the common attribute: Programming-Package-ID.