SQL-Engineering-Handbook

← Level 8 · Module Home · Level 9 (of 0–9)

Level 9 — SQL System Design

Pilot set: 6 of ~30 target questions. No single query is the deliverable here — the candidate designs schema, indexes, and query strategy for an end-to-end need, then defends the tradeoffs.


Q045 — Design a Reporting Database for a Growing Company

Difficulty: ⚫ Staff/Production Category: System Design Type: I — Design

Scenario

A company’s HR system (employes/departments/locations, this handbook’s shared schema) currently serves both transactional writes (HR staff editing records) AND analytical reporting (headcount dashboards, compliance reports) directly against the same tables. As company size grows, dashboard queries are starting to compete with and slow down transactional writes.

Candidate Task

Design an approach. Cover schema, indexing, and query strategy — not just “add a read replica” as a one-line answer.

What a Strong Answer Covers

Weak Answer

“Just add more indexes to the existing tables” — this doesn’t address the fundamental read/write workload conflict and can make transactional writes slower (more indexes to maintain per write, Module 16).

Interviewer Follow-Up

“How would you decide between a read replica alone vs. a full separate reporting schema? What signal would tell you which is sufficient?”


Q046 — Design a Subscription Revenue Model

Difficulty: ⚫ Staff/Production Category: System Design, SaaS Type: I — Design

Scenario

Design the schema for a subscription billing system that needs to support: prorated upgrades/downgrades mid-cycle, accurate MRR reporting (Q034), and historical “what did this customer’s plan look like on any given past date” queries for support/audit purposes.

Candidate Task

Propose a schema and explain your key modeling decisions.

What a Strong Answer Covers

Interviewer Follow-Up

“How would you keep the derived ‘current state’ table consistent with the event log as changes happen — synchronously in the same transaction, or asynchronously?” (Tests awareness that this is itself a real consistency-vs-complexity tradeoff, connecting back to Module 17’s transaction design content.)


Q047 — Design a Fraud Analytics Query System

Difficulty: ⚫ Staff/Production Category: System Design, Fintech Type: I — Design

Scenario

Design the data access pattern for a fraud detection system that needs to answer “has this account shown suspicious velocity in the last 5 minutes” on every transaction, in under 50ms, against a transaction table growing by millions of rows per day.

Candidate Task

Propose an approach — a single query against the full transaction table is very unlikely to meet this latency target at this scale; explain why, and what you’d do instead.

What a Strong Answer Covers

Weak Answer

Proposing to just add an index on (account_id, txn_timestamp) to the main table and calling the design complete, without addressing whether that alone can realistically hit a 50ms target as the table grows to billions of rows.

Interviewer Follow-Up

“What happens to this design if the fraud check needs to also consider patterns across MULTIPLE accounts (e.g., many small transactions from different accounts to the same destination in a short window)? Does your hot-store design still work?”


Q048 — Design a High-Volume Event Analytics System

Difficulty: ⚫ Staff/Production Category: System Design, Data Warehousing Type: I — Design

Scenario

Design a schema and query strategy for tracking and analyzing user events (page views, clicks) at a volume of ~50 million events/day, with requirements to support both real-time-ish dashboards (data within a few minutes) and deep historical analysis (cohort retention over years).

Candidate Task

Propose an approach covering ingestion, storage, and the two very different query patterns.

What a Strong Answer Covers

Weak Answer

“Just put it all in one big table and add indexes” — doesn’t address the volume (50M/day compounds fast) or the fundamentally different access patterns between the two stated requirements.

Interviewer Follow-Up

“A stakeholder wants a NEW cohort analysis dimension added six months after this system launches. How well does your design accommodate that without a full re-architecture — what did you build in intentionally to allow for this?”


Q079 — Design an Append-Only Audit Log for Compliance

Difficulty: ⚫ Staff/Production Category: System Design, Compliance Type: I — Design

Scenario

HR needs a tamper-evident audit trail of every change to employes (who changed what, when, old and new value) for compliance review, without slowing down normal transactional writes.

Candidate Task

Propose a schema and capture mechanism, and explain the tradeoffs.

What a Strong Answer Covers

Weak Answer

“Just add an updated_at timestamp column to employes” — this shows only the most recent change, not who changed what, and provides no historical trail at all.

Interviewer Follow-Up

“A regulator asks for proof that a specific salary change on a specific date wasn’t altered after the fact. Does your design actually provide that proof, or just a claim of one?”


Q080 — Design Tenant Isolation for a Multi-Tenant SaaS Schema

Difficulty: ⚫ Staff/Production Category: System Design, Multi-Tenancy Type: I — Design

Scenario

This HR system is being sold to multiple companies as SaaS. Each tenant’s employes/departments/locations data must never leak into another tenant’s queries, even under an application bug.

Candidate Task

Compare at least two isolation strategies and recommend one with justification.

What a Strong Answer Covers

Weak Answer

Recommending shared-schema-with-tenant_id as strictly superior without ever mentioning row-level security or acknowledging the leak risk of an enforcement-only-in-application-code approach.

Interviewer Follow-Up

“A large enterprise tenant now requires their data physically isolated for a compliance certification. Does your original design accommodate that for one tenant without re-architecting for all of them?”


← Level 8 · Module Home