SevyDevy

Design a double-entry payments ledger database

PremiumDatabase designHard

  • Double entry
  • Append only
  • Idempotency

Quick answer

This database design interview question asks you to design a double-entry payments ledger database. Aim for a design that stores data correctly and serves its main queries well, then explain the schema, keys, indexes and trade-offs. Interviewers want to see how you model entities, choose keys and design for the real access patterns.

The problem

Design a double-entry ledger database for a payments company. Every business event (a card payment, a payout, a refund, a fee, a chargeback) is a journal entry whose postings sum to zero, so the books always balance. The hard parts are hot accounts, exactly-once posting and daily bank reconciliation.

Money moves between customers, merchants, the company's own fee accounts and external bank accounts. Every day the partner bank sends a settlement file that must be reconciled against the ledger.

Product teams read balances constantly; finance closes the books every day and must prove that the sum of every account equals zero across the whole ledger.

What must a double-entry payments ledger database do?

  • Post a journal entry: Record a business event as a transaction (journal entry) with 2 or more postings that sum to zero, with an external idempotency key; reject if unbalanced.
  • Balance: Current balance of an account in under 10 ms; balance as of any past timestamp.
6 more requirementsUnlock to see all

How well must it do it?

  • Balanced by construction: The database rejects any transaction whose postings do not sum to zero.
  • Append-only: Postings and transactions are never updated or deleted.
4 more requirementsUnlock to see all

What scale should you design for?

Use these numbers in your estimates.

The scale numbers unlock with this questionUnlock

Key concepts

  • Double entry
  • Append only
  • Idempotency
  • Balance snapshots
  • Serializable isolation
  • Reconciliation

How you’ll practise

6 short steps · save and come back any time
  1. Access patterns
  2. Entities
  3. Schema
  4. Indexes and queries
  5. Scale and consistency
  6. Wrap-up

Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.

What do interviewers look for?

In any database design round.

  • Lists the entities and how they relate before writing tables
  • Designs the schema around the main access patterns
  • Chooses primary keys, foreign keys and indexes with reasons
  • Explains where to normalise and where to denormalise
  • Considers integrity, transactions and concurrent writes
  • Plans for growth: partitioning, archiving and migrations

Questions people ask about this interview question

Which design type is this question?
It is a database design question. You design a double-entry payments ledger database and explain your choices the way you would in an interview.
Is this question asked at entry level?
It is marked Hard. It suits engineers preparing for senior interviews, where you are expected to drive the discussion and go deep on trade-offs.
What should I cover first?
Start with the entities and the main queries the database must answer. Agree on scope with the interviewer before you design anything.
Can I practise it for free?
It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.

Related questions

Updated · Written by the SevyDevy team

Premium questionSign up free, then unlock it