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
Transactions in Data Systems
00:00
5 left

Transactions in Data Systems

MediumSQL · PostgreSQL

Problem

Explain what a transaction is and why it matters in a system that processes concurrent requests.

Using the transaction and request-operation records, write a SQL query that produces a concise summary for each recorded transaction. Include transactions with no recorded requests. Requests without a matching transaction should not appear in any transaction summary.

Output

  1. One row per transaction with transaction_id, isolation_level, status, request_count, failed_request_count, and duration_ms.
  2. Treat every response status other than 200, including NULL, as failed.
  3. Sort by duration_ms descending, then transaction_id ascending.

Schema

database_transactions
ColumnTypeDescription
transaction_idPKINTUnique database transaction identifier
isolation_levelVARCHAR(30)Isolation level used by the transaction
statusVARCHAR(30)Final transaction status
started_atTIMESTAMPTransaction start timestamp
ended_atTIMESTAMPTransaction completion timestamp
request_operations
ColumnTypeDescription
request_idPKINTUnique request identifier
transaction_idINTAssociated database transaction identifier
operationVARCHAR(30)Operation performed by the request
response_statusVARCHAR(50)Response status returned by the operation
Tablesdatabase_transactionsrequest_operations
Interviewer

Your question is Transactions in Data Systems. Start with the requirements and the two 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.