Tuesday 3 July 2012

First Normal Form


First Normal Form (INF):- A table is said to be in a First Normal Form (1NF)if it satisfy the following conditions:-
1)If the columns of the table only contain atomic values (Single, indivisible).
2)Primary key is defined for the table
3)All the columns of the table are defined on the primary key.

The first condition also implies that no column should contain the set of values.
 For example, suppose we have a table Student

Table Name :-Student
Primary Key:- StudentId

StudentId     Name                   Regdate                  Project
1                Lily                           22/04/2009              Traffic Simulator
2               Salony                       12/01/2009          Library Management,InternetLab Management
 
 Now, in the above table the column Project contains a set of values for the StudentId 2. Therefore this table is not in the 1NF form. 
 
To make this table in the 1NF, we need to break this table into two tables, one contains the student information StudentInfo (StudentId, Name, and Regdate) and the other table contains the student's project information ProjectInfo(StudentId, Project). In both the tables, StudentId will be the primary key.

Table Name:- StudentInfo
Primary Key:- StudentId

EmpId     EmpName            EmpRegdate
1               Lily                        22/04/2009
2               Salony                   12/01/2009

Table Name:- ProjectInfo
Primary Key:-( StudentId , Project)

StudentId           Project
1                         Traffic Simulator
2                         Library Management
2                         InternetLab Management


Now these tables is said to be in the 1NF since all the columns of these tables contains the atomic values and all the values of the columns are dependent on the primary keys.

No comments:

Post a Comment