Difference Between 1NF and 2NF Explained
Q: Can you explain the difference between the first normal form (1NF) and the second normal form (2NF)?
- Database Design and Normalisation
- Junior level question
Explore all the latest Database Design and Normalisation interview questions and answers
ExploreMost Recent & up-to date
100% Actual interview focused
Create Database Design and Normalisation interview for FREE!
Certainly! The first normal form (1NF) and the second normal form (2NF) are both stages in the process of database normalization, which aims to reduce redundancy and improve data integrity.
First normal form (1NF) requires that a table contains only atomic (indivisible) values and each entry in a column must be of the same data type. Moreover, each column must contain unique names, and the order in which data is stored does not matter. For example, if we have a table of students with their enrolled courses:
| StudentID | StudentName | Courses |
|-----------|-------------|------------------|
| 1 | Alice | Math, Science |
| 2 | Bob | English |
This table is not in 1NF because the "Courses" column contains non-atomic values (multiple courses in a single cell). To convert it into 1NF, we separate the courses into individual records:
| StudentID | StudentName | Course |
|-----------|-------------|----------|
| 1 | Alice | Math |
| 1 | Alice | Science |
| 2 | Bob | English |
Second normal form (2NF) builds on the foundation of 1NF. A table is in 2NF if it is in 1NF and all non-key attributes are fully functionally dependent on the entire primary key. This means that there should be no partial dependency of any column on a composite primary key. For instance, if we extend our previous example by adding a Grade for each course:
| StudentID | Course | Grade |
|-----------|----------|-------|
| 1 | Math | A |
| 1 | Science | B |
| 2 | English | A |
Assuming "StudentID" and "Course" together form the composite primary key, the table is in 2NF because "Grade" is fully dependent on both parts of the key. If we had a column for "StudentName" also listed, it could create a partial dependency:
| StudentID | StudentName | Course | Grade |
|-----------|-------------|----------|-------|
| 1 | Alice | Math | A |
| 1 | Alice | Science | B |
| 2 | Bob | English | A |
In this case, "StudentName" is only dependent on "StudentID". To achieve 2NF, we would create separate tables to eliminate this partial dependency:
Students Table:
| StudentID | StudentName |
|-----------|-------------|
| 1 | Alice |
| 2 | Bob |
Courses Table:
| StudentID | Course | Grade |
|-----------|----------|-------|
| 1 | Math | A |
| 1 | Science | B |
| 2 | English | A |
In summary, 1NF ensures atomicity and uniqueness of entries, while 2NF addresses the elimination of partial dependencies on composite keys.
First normal form (1NF) requires that a table contains only atomic (indivisible) values and each entry in a column must be of the same data type. Moreover, each column must contain unique names, and the order in which data is stored does not matter. For example, if we have a table of students with their enrolled courses:
| StudentID | StudentName | Courses |
|-----------|-------------|------------------|
| 1 | Alice | Math, Science |
| 2 | Bob | English |
This table is not in 1NF because the "Courses" column contains non-atomic values (multiple courses in a single cell). To convert it into 1NF, we separate the courses into individual records:
| StudentID | StudentName | Course |
|-----------|-------------|----------|
| 1 | Alice | Math |
| 1 | Alice | Science |
| 2 | Bob | English |
Second normal form (2NF) builds on the foundation of 1NF. A table is in 2NF if it is in 1NF and all non-key attributes are fully functionally dependent on the entire primary key. This means that there should be no partial dependency of any column on a composite primary key. For instance, if we extend our previous example by adding a Grade for each course:
| StudentID | Course | Grade |
|-----------|----------|-------|
| 1 | Math | A |
| 1 | Science | B |
| 2 | English | A |
Assuming "StudentID" and "Course" together form the composite primary key, the table is in 2NF because "Grade" is fully dependent on both parts of the key. If we had a column for "StudentName" also listed, it could create a partial dependency:
| StudentID | StudentName | Course | Grade |
|-----------|-------------|----------|-------|
| 1 | Alice | Math | A |
| 1 | Alice | Science | B |
| 2 | Bob | English | A |
In this case, "StudentName" is only dependent on "StudentID". To achieve 2NF, we would create separate tables to eliminate this partial dependency:
Students Table:
| StudentID | StudentName |
|-----------|-------------|
| 1 | Alice |
| 2 | Bob |
Courses Table:
| StudentID | Course | Grade |
|-----------|----------|-------|
| 1 | Math | A |
| 1 | Science | B |
| 2 | English | A |
In summary, 1NF ensures atomicity and uniqueness of entries, while 2NF addresses the elimination of partial dependencies on composite keys.


