Sub topic 13
First and Second Normal Form
Assume you know tables, rows, columns, candidate keys, and functional dependencies. This chapter uses those ideas to decide whether a relation satisfies first normal form (1NF) and second normal form (2NF).
First Normal Form
A relation is in 1NF when every attribute contains atomic values. An atomic value is treated as one indivisible value for the relation. Each row-column position contains one value, not a list or repeating group.
For example, this design violates 1NF:
| StudentID | StudentName | Courses |
|---|---|---|
| 101 | Mira | DBMS, OS |
Courses contains multiple values. A 1NF design stores one course enrollment per row:
| StudentID | StudentName | Course |
|---|---|---|
| 101 | Mira | DBMS |
| 101 | Mira | OS |
The table now has a possible composite key of (StudentID, Course). Repeating a student name is acceptable at this stage; normalization beyond 1NF addresses such redundancy.
1NF does not mean that every value must be physically indivisible. A date such as 2026-11-28 can be treated as one value, even though it has internal parts. The important question is whether the database design needs to manipulate those parts separately.
Second Normal Form
A relation is in 2NF when:
- It is already in 1NF.
- Every non-prime attribute is fully functionally dependent on the whole of every candidate key.
A prime attribute belongs to at least one candidate key. A non-prime attribute belongs to no candidate key. A partial dependency occurs when a non-prime attribute depends on only part of a composite candidate key.
Consider:
ENROLLMENT(StudentID, CourseID, StudentName, CourseName, Grade)
Assume the candidate key is (StudentID, CourseID). The dependencies include:
StudentID → StudentNameCourseID → CourseName(StudentID, CourseID) → Grade
StudentName depends only on StudentID, and CourseName depends only on CourseID. These are partial dependencies, so the relation is in 1NF but not 2NF.
Decompose it into:
STUDENT(StudentID, StudentName)COURSE(CourseID, CourseName)ENROLLMENT(StudentID, CourseID, Grade)
Now each non-key fact belongs to the entity or relationship it describes. The enrollment grade depends on the complete pair of identifiers.
| Relation | Key | Non-key facts |
|---|---|---|
| STUDENT | StudentID | StudentName |
| COURSE | CourseID | CourseName |
| ENROLLMENT | StudentID, CourseID | Grade |
CREATE TABLE student (
student_id INT PRIMARY KEY,
student_name VARCHAR(50) NOT NULL
);
CREATE TABLE course (
course_id INT PRIMARY KEY,
course_name VARCHAR(80) NOT NULL
);
CREATE TABLE enrollment (
student_id INT,
course_id INT,
grade CHAR(2),
PRIMARY KEY (student_id, course_id),
FOREIGN KEY (student_id) REFERENCES student(student_id),
FOREIGN KEY (course_id) REFERENCES course(course_id)
);Exercise
A 1NF relation has key (A, B) and dependencies A → C and (A, B) → D. Is it in 2NF?
Show answer
No. C is non-prime and depends only on A, a proper subset of the composite key. Move C to a relation keyed by A.