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
Cross-DB Data Consistency Validation
00:00
5 left

Cross-DB Data Consistency Validation

MediumSQL · PostgreSQL

Problem

How do you validate data consistency across multiple databases in an automated test?

Assume synchronized extracts from two databases are available in qa_source_orders and qa_target_orders. Write a SQL query that identifies records missing from either extract or containing different field values.

Output

  1. One row per inconsistent order
  2. Columns: order_id, source and target values, and consistency_status
  3. Include missing records and value mismatches, exclude consistent records, and order by order_id ascending

Schema

qa_source_orders
ColumnTypeDescription
order_idPKINTOrder identifier from the source database
customer_emailVARCHAR(255)Customer email recorded in the source database
total_amountDECIMAL(10,2)Order total recorded in the source database
order_statusVARCHAR(30)Order status recorded in the source database
qa_target_orders
ColumnTypeDescription
order_idPKINTOrder identifier from the target database
customer_emailVARCHAR(255)Customer email recorded in the target database
total_amountDECIMAL(10,2)Order total recorded in the target database
order_statusVARCHAR(30)Order status recorded in the target database
Tablesqa_source_ordersqa_target_orders
Interviewer

Your question is Cross-DB Data Consistency Validation. 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.