0
0
SQLquery~10 mins

Third Normal Form (3NF) in SQL - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Third Normal Form (3NF)
Start with a Table
Check 1NF: Atomic values?
Yes
Check 2NF: No partial dependencies?
Yes
Check 3NF: No transitive dependencies?
Yes
Result: Tables in 3NF
Start with a table, ensure it meets 1NF and 2NF, then remove transitive dependencies to achieve 3NF.
Execution Sample
SQL
CREATE TABLE Orders (
  OrderID INT PRIMARY KEY,
  CustomerID INT,
  CustomerName VARCHAR(100),
  OrderDate DATE
);
This table has a transitive dependency: CustomerName depends on CustomerID, not directly on OrderID.
Execution Table
StepCheckConditionResultAction
1Check 1NFAre all values atomic?YesProceed to 2NF check
2Check 2NFAre there partial dependencies?NoProceed to 3NF check
3Check 3NFAre there transitive dependencies?YesDecompose table
4DecomposeSplit Orders into Orders and CustomersOrders(OrderID, CustomerID, OrderDate), Customers(CustomerID, CustomerName)Tables now in 3NF
5Final CheckAre all tables in 3NF?YesNormalization complete
💡 All tables satisfy 3NF after decomposition, no transitive dependencies remain.
Variable Tracker
TableInitial ColumnsAfter DecompositionFinal Columns
OrdersOrderID, CustomerID, CustomerName, OrderDateOrders: OrderID, CustomerID, OrderDate Customers: CustomerID, CustomerNameOrders: OrderID, CustomerID, OrderDate Customers: CustomerID, CustomerName
Key Moments - 2 Insights
Why do we remove CustomerName from the Orders table?
Because CustomerName depends on CustomerID, not directly on OrderID, causing a transitive dependency (see execution_table step 3). Removing it breaks this dependency.
What does it mean for a table to have no transitive dependencies?
It means non-key columns depend only on the primary key, not on other non-key columns (refer to execution_table step 3 and 4).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step do we find transitive dependencies?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Check the 'Check 3NF' row in execution_table where transitive dependencies are identified.
According to variable_tracker, what columns does the Customers table have after decomposition?
ACustomerID, CustomerName
BOrderID, CustomerID, CustomerName
COrderID, OrderDate
DCustomerName, OrderDate
💡 Hint
Look at the 'After Decomposition' and 'Final Columns' rows for Customers in variable_tracker.
If CustomerName stayed in Orders, what problem would remain?
APartial dependency
BAtomicity violation
CTransitive dependency
DPrimary key missing
💡 Hint
Refer to execution_table step 3 where transitive dependencies are detected.
Concept Snapshot
Third Normal Form (3NF):
- Table must be in 2NF first.
- Remove transitive dependencies: no non-key column depends on another non-key column.
- Decompose tables to separate related data.
- Result: each non-key attribute depends only on the primary key.
- Ensures data integrity and reduces redundancy.
Full Transcript
Third Normal Form (3NF) is a database design principle to organize tables so that every non-key column depends only on the primary key. We start by ensuring the table is in First Normal Form (1NF) with atomic values, then Second Normal Form (2NF) with no partial dependencies. Next, we check for transitive dependencies, where a non-key column depends on another non-key column. If found, we split the table into smaller tables to remove these dependencies. For example, in an Orders table containing CustomerName, since CustomerName depends on CustomerID and not directly on OrderID, we separate Customers into its own table. This process reduces redundancy and improves data integrity. The execution table shows each step, and the variable tracker shows how columns move between tables during decomposition.