KatInterview

Dimensional Model for a Marketplace Analytics Warehouse

System DesignModel answer
HardModel answerSystem Designdata-warehousedimensional-modelingstar-schema

Last updated

Design fact and dimension tables for a marketplace to serve five business metrics, covering grain, keys, partitioning, late data, deduplication, anonymous users and changing seller attributes.

You are the data engineer for an online marketplace. The operational systems hold buyers, sellers, orders, order items, payments, and a stream of page-view events. Analysts want a warehouse that answers these five questions:

  1. Daily conversion rate from session to purchase.
  2. Average order value.
  3. Seven-day buyer retention, grouped by signup cohort.
  4. Order cancellation rate per seller.
  5. Daily gross merchandise value (GMV) per product category.

Design the warehouse model. No SQL is needed. Your answer should cover:

  • The fact and dimension tables you would build, and the grain of each.
  • Primary and foreign keys, including any surrogate keys, plus the main attributes and their data types.
  • Your partitioning and clustering choices.
  • How you handle late-arriving events, duplicate records, anonymous or null users, and seller attributes that change over time.
  • Whether you choose a star or snowflake layout, and why.

State your assumptions about scale and metric definitions up front (for example, what counts as a session and whether cancelled orders count toward average order value).

Hints

Hint 1

Pin down each metric as a numerator and a denominator first, and decide the grain of the table each one needs before you list any columns.

Hint 2

Separate event time from ingestion time, partition by event time, and reprocess a sliding window with idempotent overwrites or MERGE so late data and duplicates are corrected safely.

Hint 3

Use a surrogate key with a reserved 'unknown' row for anonymous users, build sessions on an anonymous ID with an identity-bridge table, and use Type 2 history for sellers and product categories so past metrics stay attributed correctly.