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
Maintaining Integrity During Migration
00:00
5 left

Maintaining Integrity During Migration

MediumSQL · PostgreSQL

Problem

How do you handle data integrity when migrating records between environments?

Using the supplied source_records and target_records tables, write a SQL query that identifies records requiring investigation after a migration. Compare the identifying and data attributes, and distinguish missing, extra, and changed records.

Output

  1. One row per migration exception.
  2. Columns: source_record_id, target_record_id, integrity_status, source_name, target_name, source_status, target_status.
  3. Exclude records that match completely. Order by the available record identifier ascending.

Schema

source_records
ColumnTypeDescription
record_idPKINTEGERIdentifier of the source record
nhs_numberVARCHAR(10)Illustrative NHS number value
full_nameVARCHAR(100)Name stored in the source environment
postcodeVARCHAR(10)Postcode stored in the source environment
activeBOOLEANWhether the source record is active
target_records
ColumnTypeDescription
target_record_idPKINTEGERIdentifier assigned in the target environment
source_record_idINTEGERSource identifier associated with the migrated record
nhs_numberVARCHAR(10)Illustrative NHS number value in the target
full_nameVARCHAR(100)Name stored in the target environment
postcodeVARCHAR(10)Postcode stored in the target environment
activeBOOLEANWhether the target record is active
Tablessource_recordstarget_records
Interviewer

Your question is Maintaining Integrity During Migration. 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.