Second Normal Form in Database Design
Second Normal Form in Database Design
In database design, the second normal form (2NF) is a normal form that builds on the first normal form (1NF). A table is in 2NF if it is in 1NF and every non-prime attribute is fully dependent on the primary key. A non-prime attribute is an attribute that is not a part of the primary key.
To understand 2NF, it's important to first understand 1NF. A table is in 1NF if it meets the following criteria:
- Each cell in the table contains a single value, not a list of values
- The values in a column are of the same data type
- There is a unique primary key for each row in the table
Now, let's look at 2NF. A table is in 2NF if it meets the following criteria:
- It is in 1NF (as mentioned above)
- Every non-prime attribute is fully dependent on the primary key
So, what does it mean for a non-prime attribute to be fully dependent on the primary key? It means that the value of the non-prime attribute is determined solely by the value of the primary key. In other words, if we know the value of the primary key, we can determine the value of the non-prime attribute. For example, consider the following table:
| Student ID | Student Name | Course |
|---|---|---|
| 123 | John | Computer Science |
| 124 | Jane | Computer Science |
| 125 | Bob | Mathematics |
In this table, the primary key is the "Student ID" column, and the non-prime attribute is the "Course" column. The value of the "Course" column is fully dependent on the value of the "Student ID" column, because each student ID is associated with a specific course. Therefore, this table is in 2NF.