Second Normal Form (2NF) is a database normalisation form that ensures every non-key attribute is fully dependent on the entire candidate key, not just a part of it.
- Must be in 1NF: The table must first satisfy all the requirements of First Normal Form (1NF).
- No Partial Dependency: No non-key attribute should depend on only a part of a composite candidate key.
Partial Dependency
A partial dependency occurs when a non-key attribute depends on only a part of a composite candidate key, rather than the entire key. Consider the following STUDENT_COURSE table:
| Student_ID | Course_ID | Course_Name | Course_Fee |
|---|---|---|---|
| S101 | C01 | DBMS | 1000 |
| S102 | C02 | OS | 1500 |
| S101 | C03 | CN | 1200 |
| S103 | C01 | DBMS | 1000 |
Here, the candidate key is (Student_ID, Course_ID) because both attributes together uniquely identify each record.
Course_ID → Course_Name, Course_FeeCourse_NameandCourse_Feedepend only onCourse_ID, which is a part of the composite key.- Therefore, this is a partial dependency.
Example of Second Normal Form (2NF)
Consider the following STUDENT_COURSE table:
| STUDENT_ID | COURSE_ID | COURSE_NAME | COURSE_FEE |
|---|---|---|---|
| S101 | C01 | DBMS | 1000 |
| S102 | C02 | Operating Systems | 1500 |
| S101 | C04 | Computer Networks | 2000 |
| S104 | C03 | Data Structures | 1000 |
| S104 | C01 | DBMS | 1000 |
| S102 | C05 | Java | 2000 |
The candidate key is (STUDENT_ID, COURSE_ID) because their combination uniquely identifies each record. However, COURSE_NAME and COURSE_FEE depend only on COURSE_ID, which is a part of the candidate key.
Therefore, a partial dependency exists, and the table is not in 2NF.
Converting the Table to 2NF
To remove the partial dependency, divide the table into two tables:
STUDENT_COURSE
| STUDENT_ID | COURSE_ID |
|---|---|
| S101 | C01 |
| S102 | C02 |
| S101 | C04 |
| S104 | C03 |
| S104 | C01 |
| S102 | C05 |
COURSE
| COURSE_ID | COURSE_NAME | COURSE_FEE |
|---|---|---|
| C01 | DBMS | 1000 |
| C02 | Operating Systems | 1500 |
| C03 | Data Structures | 1000 |
| C04 | Computer Networks | 2000 |
| C05 | Java | 2000 |
Now, each non-key attribute depends on the entire key of its table, so the tables satisfy 2NF.
Limitations of Second Normal Form (2NF)
- Does Not Remove Transitive Dependencies: 2NF eliminates partial dependencies but does not address transitive dependencies, where a non-key attribute depends on another non-key attribute. This is addressed by Third Normal Form (3NF).
- May Not Eliminate All Redundancy: A table can still contain some data redundancy even after achieving 2NF.
- Mainly Relevant to Composite Keys: Partial dependency occurs when a candidate key contains multiple attributes. If a table has a single-attribute candidate key, partial dependency cannot occur.
- May Require Further Normalization: 2NF may not be sufficient for a fully normalized database, so further forms such as 3NF may be required to handle other types of dependencies.