Bird
0
0

You have a table storing orders with multiple products in one column:

hard📝 Application Q15 of 15
SQL - Database Design and Normalization
You have a table storing orders with multiple products in one column:

Orders(OrderID INT, Customer VARCHAR(50), Products VARCHAR(255))
Products column stores product IDs separated by commas.

How do you redesign the schema to fully comply with First Normal Form (1NF)?
ACreate a new table OrderProducts(OrderID, ProductID) with one product per row.
BSplit Products into multiple columns like Product1, Product2, Product3.
CStore Products as JSON array in the same column.
DKeep Products column but restrict to one product ID only.
Step-by-Step Solution
Solution:
  1. Step 1: Identify 1NF violation in current design

    Storing multiple product IDs in one column violates 1NF because values are not atomic.
  2. 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.
  3. Final Answer:

    Create a new table OrderProducts(OrderID, ProductID) with one product per row. -> Option A
  4. Quick Check:

    Separate repeating data into rows for 1NF compliance [OK]
Quick Trick: 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

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes