0
0
SQLquery~20 mins

Third Normal Form (3NF) in SQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
3NF Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the Purpose of 3NF

Which of the following best describes the main goal of the Third Normal Form (3NF) in database design?

ATo eliminate transitive dependencies and ensure that non-key attributes depend only on the primary key.
BTo remove duplicate rows from a table by enforcing unique constraints.
CTo combine multiple tables into one to reduce the number of joins needed.
DTo allow null values in foreign key columns to enable optional relationships.
Attempts:
2 left
💡 Hint

Think about what kind of dependencies 3NF tries to remove to avoid data anomalies.

query_result
intermediate
2:00remaining
Identifying Transitive Dependency

Consider the table below:

EmployeeID | EmployeeName | DepartmentID | DepartmentName
-----------------------------------------------------
1          | Alice        | 10           | Sales
2          | Bob          | 20           | Marketing
3          | Carol        | 10           | Sales

Which column(s) cause a transitive dependency violating 3NF?

ADepartmentID depends on EmployeeName, causing transitive dependency.
BDepartmentName depends on DepartmentID, which is not a key, causing transitive dependency.
CEmployeeID depends on DepartmentName, causing transitive dependency.
DEmployeeName depends on EmployeeID, which is a primary key, so no transitive dependency.
Attempts:
2 left
💡 Hint

Look for columns that depend on other non-key columns instead of the primary key.

schema
advanced
3:00remaining
Decomposing a Table into 3NF

You have a table:

Orders(OrderID, CustomerID, CustomerName, CustomerAddress, ProductID, ProductName, Quantity)

Which of the following decompositions correctly achieves 3NF?

AOrders(OrderID, CustomerID, ProductID), Customers(CustomerName, CustomerAddress), Products(ProductName, Quantity)
BOrders(OrderID, CustomerName, CustomerAddress, ProductName, Quantity), Customers(CustomerID), Products(ProductID)
COrders(OrderID, CustomerID, CustomerName, CustomerAddress, ProductID, ProductName, Quantity)
DOrders(OrderID, CustomerID, ProductID, Quantity), Customers(CustomerID, CustomerName, CustomerAddress), Products(ProductID, ProductName)
Attempts:
2 left
💡 Hint

3NF requires removing transitive dependencies by separating entities into their own tables.

optimization
advanced
2:30remaining
Optimizing Queries on 3NF Tables

Given a database normalized to 3NF with separate tables for Customers, Orders, and Products, which query approach is most efficient to get the total quantity ordered by each customer?

AJoin Customers and Products tables directly without Orders table.
BQuery the Orders table only and sum quantities without joining other tables.
CUse JOINs between Customers and Orders tables with GROUP BY CustomerID.
DUse nested subqueries to fetch customer names for each order separately.
Attempts:
2 left
💡 Hint

Think about which tables contain the necessary data and how to combine them efficiently.

🔧 Debug
expert
3:00remaining
Identifying 3NF Violation in SQL Table Definition

Examine the following SQL table definition:

CREATE TABLE Employee (
  EmployeeID INT PRIMARY KEY,
  EmployeeName VARCHAR(100),
  DepartmentID INT,
  DepartmentName VARCHAR(100),
  FOREIGN KEY (DepartmentID) REFERENCES Department(DepartmentID)
);

What is the main problem violating 3NF in this design?

ADepartmentName is stored in Employee table causing transitive dependency on DepartmentID.
BEmployeeID should not be the primary key because it is not unique.
CForeign key constraint is missing on DepartmentID.
DEmployeeName depends on DepartmentName causing circular dependency.
Attempts:
2 left
💡 Hint

Check if any non-key column depends on another non-key column.