Organizing a Customer Orders Table into First Normal Form (1NF)
📖 Scenario: You work at a small online store. The store keeps track of customer orders in a table. Currently, the orders table has a problem: some columns contain multiple values in one cell, which makes it hard to work with the data.Your job is to fix this by organizing the data into First Normal Form (1NF). This means each column should hold only one value per row, making the table easier to use and understand.
🎯 Goal: You will create a new table that follows First Normal Form (1NF) rules. This means no repeating groups or multiple values in a single column. Each order item will have its own row with one product per row.
📋 What You'll Learn
Create an initial table with customer orders where some columns have multiple values
Add a helper variable to identify the order to split
Write a query to split the multiple product values into separate rows
Create a new table that stores the orders in 1NF format with one product per row
💡 Why This Matters
🌍 Real World
Organizing data into First Normal Form helps businesses keep their databases clean and easy to use, especially when dealing with orders, customers, or inventory.
💼 Career
Database administrators and developers often need to normalize data to improve database design, performance, and maintainability.
Progress0 / 4 steps
1
Create the initial orders table with multiple products in one column
Write a SQL statement to create a table called orders with columns order_id (integer), customer_name (text), and products (text). Insert one row with order_id 1, customer_name 'Alice', and products 'apple, banana, orange' (all products in one string).
SQL
Hint
Use CREATE TABLE to define the table and INSERT INTO to add the row.
2
Add a variable to identify the order to split
Write a SQL variable or CTE named order_to_split that selects the row from orders where order_id is 1.
SQL
Hint
Use a WITH clause to create a CTE named order_to_split.
3
Split the products into separate rows using a query
Write a SQL query that uses order_to_split and splits the products string into separate rows, one product per row. Use STRING_SPLIT(products, ',') or an equivalent function to split the string. Select order_id, customer_name, and each product as a separate row.
SQL
Hint
Use CROSS APPLY STRING_SPLIT(products, ',') to split the products string into rows.
4
Create a new table with orders in First Normal Form (1NF)
Write a SQL statement to create a new table called orders_1nf with columns order_id (integer), customer_name (text), and product (text). Insert the split rows from the previous query into orders_1nf so each product has its own row.
SQL
Hint
Create the new table and insert the split rows using the same splitting query.
Practice
(1/5)
1. What does First Normal Form (1NF) require in a database table?
easy
A. Each table must have a primary key.
B. Tables must have at least two columns.
C. Each column must contain atomic (single) values only.
D. Columns can contain lists or multiple values.
Solution
Step 1: Understand 1NF definition
1NF requires that each column holds only one atomic value per row, no lists or sets.
Step 2: Evaluate options
Each column must contain atomic (single) values only. matches the 1NF rule exactly. Options A, B, and D describe other concepts or violate 1NF.
Final Answer:
Each column must contain atomic (single) values only. -> Option C
Quick Check:
1NF = atomic columns only [OK]
Hint: 1NF means no multiple values in one cell [OK]
Common Mistakes:
Thinking 1NF requires a primary key
Allowing lists or sets in columns
Confusing 1NF with other normal forms
2. Which of the following SQL table definitions violates First Normal Form (1NF)?
easy
A. CREATE TABLE Students (ID INT, Name VARCHAR(50), PhoneNumbers VARCHAR(100));
B. CREATE TABLE Students (ID INT PRIMARY KEY, Name VARCHAR(50), PhoneNumber VARCHAR(15));
C. CREATE TABLE Students (ID INT, Name VARCHAR(50), Email VARCHAR(50));
D. CREATE TABLE Students (ID INT, Name VARCHAR(50), Address VARCHAR(100));
Solution
Step 1: Identify 1NF violation in table definitions
CREATE TABLE Students (ID INT, Name VARCHAR(50), PhoneNumbers VARCHAR(100)); uses PhoneNumbers as VARCHAR(100), likely storing multiple numbers in one field, violating 1NF.
Step 2: Check other options
Options A, B, and C have single atomic values per column, so they follow 1NF.
Final Answer:
CREATE TABLE Students (ID INT, Name VARCHAR(50), PhoneNumbers VARCHAR(100)); -> Option A
Quick Check:
Multiple values in one column break 1NF [OK]
Hint: Multiple values in one column break 1NF [OK]
Common Mistakes:
Assuming VARCHAR can hold multiple values without issue
Confusing primary key with 1NF rules
Ignoring column data types when checking 1NF
3. Given the table below, which row violates First Normal Form (1NF)?
Orders(OrderID, Customer, Items) Where Items column contains comma-separated product IDs.
Row 2 has 'P2,P3' in Items, which is multiple values in one cell, violating 1NF.
Step 2: Check other rows
Rows 1, 3, and 4 have single product IDs, so they follow 1NF.
Final Answer:
Row 2 -> Option B
Quick Check:
Multiple values in one cell break 1NF [OK]
Hint: Comma-separated values in one cell break 1NF [OK]
Common Mistakes:
Ignoring multiple values separated by commas
Assuming string with commas is atomic
Not checking all rows carefully
4. You have this table definition violating 1NF:
CREATE TABLE Employees (ID INT, Name VARCHAR(50), Skills VARCHAR(100));
Skills column stores multiple skills separated by commas. Which SQL change fixes the 1NF violation?
medium
A. Store skills as a single string with semicolons instead of commas.
B. Change Skills to TEXT and store JSON arrays.
C. Keep Skills as VARCHAR but limit length to 50.
D. Create a separate Skills table with EmployeeID and Skill columns.
Solution
Step 1: Identify 1NF violation and fix approach
Storing multiple skills in one column violates 1NF. The fix is to separate repeating data into another table.
Step 2: Evaluate options for 1NF compliance
Create a separate Skills table with EmployeeID and Skill columns. creates a separate Skills table with one skill per row, fixing 1NF. Options B, C, and D still store multiple values in one column.
Final Answer:
Create a separate Skills table with EmployeeID and Skill columns. -> Option D
Quick Check:
Separate repeating data into new table for 1NF [OK]
Hint: Use separate table for repeating groups to fix 1NF [OK]
Common Mistakes:
Trying to store multiple values in one column anyway
Using JSON or delimiters inside one column
Not normalizing repeating data into separate tables
5. You have a table storing orders with multiple products in one column:
How do you redesign the schema to fully comply with First Normal Form (1NF)?
hard
A. Create a new table OrderProducts(OrderID, ProductID) with one product per row.
B. Split Products into multiple columns like Product1, Product2, Product3.
C. Store Products as JSON array in the same column.
D. Keep Products column but restrict to one product ID only.
Solution
Step 1: Identify 1NF violation in current design
Storing multiple product IDs in one column violates 1NF because values are not atomic.
Step 2: Choose redesign that enforces atomicity
Create a new table OrderProducts(OrderID, ProductID) with one product per row. creates a new table with one product per row, fully normalizing the data and satisfying 1NF. Split Products into multiple columns like Product1, Product2, Product3. uses multiple columns but is limited and not scalable. Options C and D still violate 1NF.
Final Answer:
Create a new table OrderProducts(OrderID, ProductID) with one product per row. -> Option A
Quick Check:
Separate repeating data into rows for 1NF compliance [OK]
Hint: Use separate table with one value per row for 1NF [OK]
Common Mistakes:
Adding multiple columns instead of rows
Using JSON or arrays inside one column
Restricting to one product but losing data
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.