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
Merge, Keys, and Large Data Migration
00:00
5 left

Merge, Keys, and Large Data Migration

MediumSQL · PostgreSQL

Problem

Explain how a MERGE statement works in SQL, how primary and foreign keys differ, and how you would migrate large data safely.

Use the tables below as the reference schema for your answer. Keep the response focused on the SQL behavior, key constraints, and a safe migration approach.

Output

  1. Return one row with three columns: merge_behavior, key_difference, and safe_migration_plan.
  2. merge_behavior should summarize when rows are inserted, updated, or left unchanged.
  3. key_difference should summarize how primary keys and foreign keys enforce different integrity rules.
  4. safe_migration_plan should summarize a safe approach for moving large data with minimal risk and downtime.

Schema

source_rows
ColumnTypeDescription
row_idPKINTSource row identifier
business_keyVARCHAR(50)Natural key used to match rows
payloadVARCHAR(100)Example source value
target_rows
ColumnTypeDescription
row_idPKINTTarget row identifier
business_keyVARCHAR(50)Natural key used to match rows
payloadVARCHAR(100)Example target value
Tablessource_rowstarget_rows
Interviewer

Your question is Merge, Keys, and Large Data 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.