A customer buys two desk lamps at $30 each. The seller later raises the price to $35. When the customer opens their order history, it shows $70. Every query might have executed correctly; the model remembered which product was purchased but lost the price agreed to for that purchase.
We will build a small store model from its required behavior, then change one requirement. The goal is to derive and defend the important identities, relationships, and facts, not to produce an exhaustive production schema. You should be comfortable reading a table and following an ID between records.
Why the data model matters
A data model specifies what the system remembers, what each fact means, how records relate, and which states are valid.
A record represents something the product needs to distinguish, such as a particular order. Its fields describe that thing. Relationships connect it to other records, while rules state what combinations make sense. A schema expresses parts of this model through tables or documents, fields, keys, and constraints.
The difficult decision in our broken receipt is what “price” means. Today's catalog price and the price accepted yesterday answer different questions. Choosing a database or making the query faster cannot recover a fact we never retained.
For engineering work, a model makes these decisions explicit before different features develop conflicting assumptions. It gives us a way to check whether a change preserves the product's promises. In an interview, a small model makes the same reasoning inspectable: the interviewer can see what you think the system does, question an assumption, and follow your adaptation. In both settings, you should be able to connect each important modeling decision to the behavior it supports.
Start with what the product needs to do and remember
The operations a product supports and the questions it must answer determine which facts are worth storing.
Our store needs to show today's products, accept purchases containing several items, and display previous receipts. Those are different reads and writes. Opening a product asks, “What is offered now?” Opening a receipt asks, “What did this customer purchase on that occasion?”
We will require each receipt to retain purchased quantities, agreed unit prices, and the product titles shown at checkout. That last requirement is a choice: another product might show current titles on old orders. We need to establish the intended behavior before deciding where the title belongs.
Each order uses one currency. Prices are stored in that currency's minor unit; in our USD examples, 3000 means $30. Checkout must establish that the accepted item prices use the order's currency. Inventory, tax, shipping, and external payment processing are outside this initial model.
Start with Product and Order. An order containing only product IDs can identify the catalog entries involved. But where would we put the fact that this order bought two lamps? Quantity describes the product's participation in a particular purchase. We have found a missing record by tracing an operation, rather than by guessing more nouns.