Code Room
System designHardsd-g305
Subject DatabasesLevel Senior–Staff~50 minCommon in Databases & SQL interviewsIndustries Technology, Software development

Question

Design the storage and maintenance of an incrementally-maintained materialized view that powers a real-time merchant dashboard: 'per-merchant, per-day count and sum(amount) of completed orders', over a base orders table taking 100k writes/sec (inserts, plus status updates that flip an order to/from 'completed', plus refunds/deletes). A full recompute is far too expensive and too stale. Design how the view is stored, how each base-table change updates it incrementally and correctly (including updates and deletes, not just inserts), and the consistency/staleness trade-off the merchant sees.

What a strong answer looks like

Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts — data model, bottlenecks, consistency, failure modes — and name the trade-offs you are making.

Narrate your design
Loading whiteboard…
Run or narrate your approach, then ask the coach.