Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Multi-Tenant Ledger Schema
00:00
5 left

Multi-Tenant Ledger Schema

HardSQL · PostgreSQL

Problem

How would you design a database schema for Mercury that supports a multi-tenant ledger system where startups can track internal transactions?

Use the provided relational model to produce a tenant-isolated account summary for posted transactions during January 2025. Include accounts with no qualifying activity.

Output

  1. One row per Mercury account.
  2. Columns: startup_name, account_id, account_name, balance_cents, posted_transaction_count, latest_posted_at, and balance_rank.
  3. Include only activity from the account's startup, exclude non-posted or out-of-range transactions, and treat missing activity as zero.
  4. Order by startup, balance rank ascending, then account ID ascending.

Schema

startups
ColumnTypeDescription
idPKINTMercury startup tenant identifier
startup_nameVARCHAR(100)Startup legal or display name
ledger_accounts
ColumnTypeDescription
idPKINTLedger account identifier
startup_idINTOwning startup tenant
account_nameVARCHAR(100)Human-readable account name
account_typeVARCHAR(30)Account classification
ledger_transactions
ColumnTypeDescription
idPKINTLedger transaction identifier
startup_idINTOwning startup tenant
occurred_atDATETransaction business date
descriptionTEXTOptional transaction description
statusVARCHAR(20)Transaction lifecycle status
ledger_entries
ColumnTypeDescription
idPKINTLedger entry identifier
transaction_idINTParent ledger transaction
account_idINTAccount affected by the entry
amount_centsBIGINTSigned amount in the smallest currency unit
Tablesstartupsledger_accountsledger_transactionsledger_entries
Interviewer

Your question is Multi-Tenant Ledger Schema. Start with the requirements and the four tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.