0
0
SQLquery~20 mins

Why normalization matters in SQL - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Normalization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Identify the problem caused by lack of normalization

Consider a table storing customer orders where customer details are repeated in every order row. What issue does this cause?

SQL
CREATE TABLE Orders (
  OrderID INT,
  CustomerName VARCHAR(100),
  CustomerAddress VARCHAR(200),
  Product VARCHAR(100),
  Quantity INT
);

INSERT INTO Orders VALUES
(1, 'Alice', '123 Maple St', 'Book', 2),
(2, 'Alice', '123 Maple St', 'Pen', 5),
(3, 'Bob', '456 Oak St', 'Notebook', 1);
APrevents data from being updated
BFaster queries because all data is in one table
CNo issues; this is the best design
DData redundancy leading to wasted storage and potential inconsistencies
Attempts:
2 left
💡 Hint

Think about what happens if Alice changes her address.

🧠 Conceptual
intermediate
1:30remaining
Purpose of normalization in databases

What is the main goal of normalization in database design?

ATo organize data to reduce redundancy and improve data integrity
BTo make tables as large as possible for performance
CTo encrypt data for security
DTo store all data in a single table for simplicity
Attempts:
2 left
💡 Hint

Normalization helps keep data consistent and avoids repetition.

📝 Syntax
advanced
2:30remaining
Identify the correct SQL to create normalized tables

Which SQL option correctly splits customer and order data into two normalized tables?

A
CREATE TABLE Customers (CustomerID INT PRIMARY KEY, Name VARCHAR(100), Address VARCHAR(200));
CREATE TABLE Orders (OrderID INT PRIMARY KEY, CustomerID INT, Product VARCHAR(100), Quantity INT, FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID));
BCREATE TABLE Orders (OrderID INT PRIMARY KEY, CustomerName VARCHAR(100), CustomerAddress VARCHAR(200), Product VARCHAR(100), Quantity INT);
CCREATE TABLE CustomersOrders (CustomerID INT, Name VARCHAR(100), Address VARCHAR(200), OrderID INT, Product VARCHAR(100), Quantity INT);
D
CREATE TABLE Customers (CustomerID INT, Name VARCHAR(100));
CREATE TABLE Orders (OrderID INT, Product VARCHAR(100), Quantity INT);
Attempts:
2 left
💡 Hint

Look for separate tables with a foreign key linking orders to customers.

optimization
advanced
2:00remaining
Effect of normalization on database updates

How does normalization affect the process of updating customer address information?

AIt requires updating every order row with the new address
BIt makes updates slower because data is spread across many tables
CIt simplifies updates by storing the address in one place, reducing errors
DIt prevents any updates to customer information
Attempts:
2 left
💡 Hint

Think about how many places you must change the address in a normalized design.

🔧 Debug
expert
2:30remaining
Detect anomaly caused by denormalized design

Given this denormalized table, what anomaly might occur if a customer changes their phone number?

Orders
OrderID | CustomerName | PhoneNumber | Product
1       | John Doe     | 555-1234    | Laptop
2       | John Doe     | 555-1234    | Mouse
3       | Jane Smith   | 555-5678    | Keyboard
AFaster retrieval of phone numbers for orders
BInconsistent phone numbers if some rows are not updated
CNo anomalies; phone number is always correct
DPhone numbers cannot be stored in this table
Attempts:
2 left
💡 Hint

What happens if John Doe's phone number changes but only one order row is updated?