Overview
Curated: · Written: · Reviewed:
Data Modeling Standards
In one line
Governed rules for grain, keys, types, nulls, history, naming, metadata and change control, so independently built pipelines combine data without silent semantic drift. Reach for it when several producers and consumers share entities, or when a change can break readers you do not control.
Key definitions
- Grain: what one row represents, and at which event or snapshot boundary.
- Natural key: a business identifier from the domain. It can change or be reused.
- Surrogate key: warehouse row identity. It proves nothing about real-world uniqueness.
- Conformed dimension: a shared entity with compatible keys and definitions across facts.
- Type 2 history: a new dimension row per tracked change, joined on validity interval to get the as-was attributes.
- Sentinel value: a stand-in such as 0 or 'unknown' that masquerades as real data.
Formulas and complexity
With the two NULL minutes replaced by 0, the same average over the 10-minute window is . The dashboard reports 96 ms against a true 120 ms over the eight measured minutes.
How it works
State the grain of each table and the business entity behind each key. Validate types at ingestion, then enforce invariants with constraints where the database can. Resolve shared identities through a crosswalk on natural keys across sources. Record history with explicit validity intervals. Change schemas only through compatibility checks and staged renames.
When to use and when not to
| Situation | Apply the standard fully | Lighter approach |
|---|---|---|
| Several producers and consumers share an entity | Yes: conformed keys, controlled mappings | None |
| One team, one pipeline, short-lived table | Usually not | Local conventions and tests |
| Timestamps from several regions | Yes: state instant or civil time, and zone | None |
| Proposal for one physical enterprise model | Rarely | Controlled mappings across models |
| Column rename on a widely read table | Yes: alias or staged migration | Never a direct rename |
Traps interviewers probe
- Summing a non-additive or parent-level value across child rows. A per-order counter on an order-line table is repeated on every line, so SUM counts it again. Fix: state the grain, store order-level attributes in an order table, and sum measures only at their own grain.
- Treating the surrogate key as a deduplicator. Two sources with the same company get two surrogate keys. Fix: resolve identity through a crosswalk on natural keys, and use the surrogate only to identify rows.
- Storing money as binary floating point. Python float and Java double cannot represent $0.025 exactly, so round-half-even can disagree with an exact decimal calculation. Fix: use an exact decimal or integer minor-unit type with currency, and apply the rounding rule explicitly.
- Filling timestamps from a server's local clock into a zone-less column. Wall-clock times from different zones are indistinguishable, and a repeated fall-back hour cannot be ordered. Fix: store an absolute instant (timestamp with time zone, in UTC) or record the zone alongside civil time.
- Replacing NULL with 0 to make a backfill pass. The average falls from 120 to 96 and the missing data disappears. Fix: keep NULL, count the gaps, and use an explicit status field when the reason matters.
Interview tips
Open with the grain and the key scope: "One row per order line, keyed on order_id plus line_number, with customer as a conformed dimension." Then name the type and nullability choices.
Expect these follow-ups:
- Which timestamp is the business date and which is the load time? Query the business date for reporting and the load time for auditing and backfills.
- How do you join facts to history? Use a Type 2 validity interval with inclusive or exclusive bounds stated, and never join on a current flag alone.
- Can you add a field safely? Adding a field can break strict or generated readers. In Avro, a default applies when the reader schema has a field the writer lacks; it does not backfill stored files or make the field optional at write time.
- How do you delete data you must keep? Keep the referencing rows, and remove the foreign key on that table with the retention rule recorded in metadata.
30-second outline: name the grain, name the keys and their scope, state the exact types for money and time, say how NULL is kept distinct, state the history and evolution rule, then name the owner and the check that enforces it, such as a constraint or a contract test.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.