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
SQL Update/Delete Constraints
00:00
5 left

SQL Update/Delete Constraints

HardSQL · PostgreSQL

Problem

Explain how you would delete or update rows in Salesforce using only SELECT and INSERT operations.

Provide a PostgreSQL statement that reads the Salesforce contact snapshot and inserts a change plan representing required updates or deletions. Do not directly modify the snapshot table.

Output

  1. One row per eligible contact, with plan_id, contact_id, operation, replacement_status, and replacement_phone.
  2. Include inactive contacts, contacts with missing phone numbers, and deleted contacts. Sort by contact_id ascending.

Schema

salesforce_contact_snapshot
ColumnTypeDescription
contact_idPKINTSalesforce Contact identifier
statusVARCHAR(20)Current Contact status
phoneVARCHAR(20)Current phone number
is_deletedBOOLEANWhether Salesforce marked the Contact as deleted
salesforce_contact_change_plan
ColumnTypeDescription
plan_idPKINTChange plan identifier
contact_idINTReferenced Salesforce Contact identifier
operationVARCHAR(10)Planned operation, UPDATE or DELETE
replacement_statusVARCHAR(20)Status to apply for an update
replacement_phoneVARCHAR(20)Phone number to apply for an update
Tablessalesforce_contact_snapshotsalesforce_contact_change_plan
Interviewer

Your question is SQL Update/Delete Constraints. 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.