Third Normal Form (3NF) in DBMS Theory - Time & Space Complexity
When organizing data in a database using Third Normal Form (3NF), we want to understand how the work needed to check and enforce 3NF grows as the database size increases.
We ask: How does the effort to ensure 3NF change when the number of records or attributes grows?
Analyze the time complexity of checking if a database table is in 3NF.
-- Assume a table with attributes and functional dependencies
-- Steps to check 3NF:
-- 1. Identify all candidate keys
-- 2. For each functional dependency (FD):
-- a. Check if FD is trivial or if determinant is a superkey
-- b. Check if dependent attributes are prime (part of any key)
-- 3. Confirm all FDs meet 3NF rules
This process involves examining keys and dependencies to ensure no unwanted data duplication or anomalies.
Look at what repeats during the 3NF check:
- Primary operation: Checking each functional dependency against candidate keys and prime attributes.
- How many times: Once for every functional dependency in the table.
As the number of functional dependencies (FDs) and attributes grows, the checking work grows roughly in proportion.
| Input Size (number of FDs) | Approx. Operations |
|---|---|
| 10 | About 10 checks |
| 100 | About 100 checks |
| 1000 | About 1000 checks |
Pattern observation: The work grows linearly as the number of functional dependencies increases.
Time Complexity: O(n * m)
This means the time to check 3NF grows in proportion to the number of functional dependencies (n) and the number of attributes (m), since checking candidate keys and prime attributes involves attribute-level operations.
[X] Wrong: "Checking 3NF takes the same time no matter how many dependencies there are."
[OK] Correct: Each functional dependency must be checked, so more dependencies mean more work.
Understanding how the effort to enforce 3NF grows helps you explain database design choices clearly and shows you can think about efficiency in organizing data.
"What if the number of attributes grows but the number of functional dependencies stays the same? How would the time complexity change?"