Skip to main content

Practice ยท 1 of 2

Decompose the denormalized table

Implement decompose(rows) โ€” rows are dicts with keys customer_id, customer_name, order_id, total (a flat order report). Return (customers, orders): - customers: dict mapping customer_id โ†’ customer_name - orders: list of {'order_id', 'customer_id', 'total'} dicts, in first-seen order of order_id (duplicates of an order_id are ignored) - redundancy must be consistent: if the same customer_id appears with two different names, raise ValueError('conflicting customer name') This is normalization as code: eliminate the redundancy, keep the truth.

Difficulty: advanced

Back to lesson: Practice: Schema & Query Drills