Data Modeling and Management
Model first, then code
Data modeling questions reward one simple test: what must the relationship do? A lookup is a loose association - both objects keep their own owner and sharing, and deleting the parent leaves children in place. A master-detail is composition - the child inherits the parent's owner and sharing, is cascade-deleted with the parent, and can be summarized by a roll-up summary on the parent. A child can have at most two master-detail relationships, which is why many-to-many designs use a junction object with two of them.
Concepts to name
- Field types and their traps: formula fields are computed at read time and cannot be edited; roll-up summaries work only across master-detail and cannot roll up a formula field on the child.
- External IDs: unique identifiers from an outside system, used as upsert keys and as relationship targets.
- Data tools: Data Import Wizard for smaller, simpler loads; Data Loader for bulk, scheduled, export and delete operations.
- Data skew: ownership skew (one user owning a very large share of an object's records) and lookup skew (one parent with a very large number of children) degrade performance and sharing recalculation.
Trap
Roll-up summary fields only exist on the master side of a master-detail relationship. If a question asks how to count child records across a lookup, the answer is a cross-object formula for a single record or Apex/flow for real aggregation - not a roll-up.
Worked example
Requirements: "An invoice line must never exist without its invoice, and deleting an invoice should remove its lines. The invoice page should show the total of its lines." Both clues point one way - master-detail on the line, plus a roll-up summary on the invoice. Choosing lookup forces you to write a trigger for cascade behavior and another for the total.
Rule of thumb
If the child cannot exist without the parent and the parent should summarize children, choose master-detail. If either side needs its own ownership, or the link is optional, choose lookup.