SQLQuestion 11 of 14
The relational model and normalisation
Answer out loud or in your head first, then compare.
Answer
Normalisation limits duplicated facts and update anomalies. In a shop model I separate customers, orders, products and order items, with foreign keys.
customers(id, name)
orders(id, customer_id)
products(id, name, current_price)
order_items(order_id, product_id, quantity, unit_price)To be precise: unit_price on an order item is the historical price, not a wrongful duplicate of the product's current price.
Pitfall: I don't store a list of IDs as comma-separated text. I choose denormalisation deliberately, for a specific measurement, and decide how I'll keep the data consistent.
The report in the comments is about a design task; the shop shown is our own practice example.
How did it go? Be honest — “Not yet” puts the question on your review list.