Schema design · Concept
Normalise this orders table
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
What is normalization? Take this table and normalise it to third normal form: orders(order_id, customer_name, customer_phone, customer_city, product_ids, product_names, total).
Then
Follow-ups the interviewer asks next
- What problems does the original table have?
- Explain 2NF and 3NF in one line each, using this example.
- Should
order_itemsstore the product's price, or always read it fromproducts? - Is storing
totalonordersa violation? Would you keep it? - What is BCNF, briefly?
The answer
What a strong answer covers
- Problems: a comma-separated list of products (not atomic), the customer's phone repeated on every order (update anomaly), no way to store a customer without an order (insert anomaly).
- 1NF: one value per cell, so products move to
order_itemsrows. 2NF: nothing depends on only part of a composite key (product_namedepends onproduct_idalone, so it moves toproducts). 3NF: no non-key column depends on another non-key column (customer_citydepends on the customer, so it moves tocustomers). - Result:
customers,products,orders(customer_id, …),order_items(order_id, product_id, qty, unit_price). unit_priceonorder_itemsis the price at the time of purchase, a different fact from today's price, so it belongs there.totalis derived; keeping it is a deliberate denormalisation for speed and audit, and must match the items.- BCNF: every determinant is a candidate key; it differs from 3NF only in unusual overlapping-key cases.
The red pen
Common traps
Avoid:reciting definitions without applying them; removing unit_price from order items "because it's in products".
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.