![]() |
VOOZH | about |
Second Normal Form (2NF) is based on the concept of fully functional dependency. It is a way to organize a database table so that it reduces redundancy and ensures data consistency. Fully Functional Dependency means a non-key attribute depends on the entire primary key, not just part of it.
For a table to be in 2NF, it must first meet the following requirements
1. Meet 1NF Requirements: The table must first satisfy First Normal Form (1NF), meaning:
2. Eliminate Partial Dependencies: A partial dependency occurs when a non-prime attribute (not part of the candidate key) depends only on a part of a composite primary key, rather than the entire key.
By ensuring these steps, a table in 2NF is more efficient and less prone to errors during updates, inserts, and deletes.
The FD (functional dependency) A->B happens to be a partial dependency if B is functionally dependent on A, and also B can be determined by any other proper subset of A.
In other words, if you have a composite key (a primary key made up of more than one attribute), and an attribute depends on only a subset of that composite key, rather than the entire key, that is considered a partial dependency.
A partial dependency would occur whenever a non-prime attribute depends functionally on a part of the given candidate key.
Example:
In the given relation StaffBranch, we have the functional dependency:
This means that the combination of staffNo and sName determines branchNo.
BranchNo is also functionally dependent on a subset of the composite key, specifically staffNo. This means that branchNo can be determined by just staffNo.
This is a partial dependency because branchNo depends on only a part of the composite key (staffNo, sName), not the entire key.
Consider a table storing information about students, courses, and their fees:
π courses_table3{STUD_NO, COURSE_NO} because the combination of these two columns uniquely identifies each row in the table.{STUD_NO, COURSE_NO}. In 2NF, we eliminate such dependencies by breaking the table into two separate tables:
Now, each table is in 2NF:
COURSE_FEE depends only on COURSE_NO.Now, the COURSE_FEE is no longer repeated in every row, and each table is free from partial dependencies. This makes the database more efficient and easier to maintain.
While Second Normal Form (2NF) addresses partial dependencies and helps reduce redundancy, it has some limitations:
1. Doesn't Handle Transitive Dependencies: 2NF ensures that non-prime attributes are fully dependent on the entire primary key, but it doesn't address transitive dependencies. In a transitive dependency, an attribute depends on another non-key attribute.
For example, if A β B and B β C, then A indirectly determines C. This can lead to further redundancy and anomalies.
2. Doesn't Ensure Optimization: Although 2NF eliminates partial dependencies, it may still leave some redundancy in the data, particularly when dealing with larger and more complex datasets. It doesnβt guarantee the most efficient or optimized structure for a database.
3. Complexity in Handling Multi-Attribute Keys: When dealing with composite primary keys (keys made of multiple attributes), ensuring full dependency can still lead to a complex design. A further step of normalization (Third Normal Form or 3NF) is required to resolve transitive dependencies and achieve better data organization.
4. Not Sufficient for Some Use Cases: While 2NF is useful for reducing redundancy in some situations, in real-world applications where data integrity and efficiency are crucial, additional normalization (like 3NF) might be needed to address more complex dependencies and optimize data storage and retrieval.