Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Scalable Transaction Logging Schema
00:00
5 left

Scalable Transaction Logging Schema

HardSQL · PostgreSQL

Problem

How would you design a scalable database schema to handle high-volume transaction logging and reporting requirements? Use the provided schema to produce a monthly report for active Mastercard merchants from January through March 2025, considering only transactions whose latest event is SETTLED.

Output

  1. One row per active merchant and reporting month, including months with no settled transactions
  2. Columns: merchant_id, merchant_name, report_month, transaction_count, total_amount, prior_month_amount, month_over_month_pct, and cumulative_amount
  3. Order by merchant_id, then report_month ascending

Schema

merchants
ColumnTypeDescription
merchant_idPKINTUnique Mastercard merchant identifier
merchant_nameVARCHAR(120)Merchant display name
merchant_categoryVARCHAR(60)Merchant business category
is_activeBOOLEANWhether the merchant is active for reporting
transaction_log
ColumnTypeDescription
transaction_idPKBIGINTUnique transaction identifier
merchant_idINTMerchant associated with the transaction
created_atTIMESTAMPTransaction creation timestamp
amountNUMERIC(12,2)Transaction amount in the transaction currency
currencyVARCHAR(3)ISO 4217 currency code
transaction_events
ColumnTypeDescription
event_idPKBIGINTMonotonically increasing event identifier
transaction_idBIGINTTransaction whose state changed
event_typeVARCHAR(30)Transaction lifecycle state
event_atTIMESTAMPTime at which the event occurred
Tablesmerchantstransaction_logtransaction_events
Interviewer

Your question is Scalable Transaction Logging Schema. Start with the requirements and the three 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.