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
Implementing SCD for Lead Times
00:00
5 left

Implementing SCD for Lead Times

HardSQL · PostgreSQL

Problem

If we need to track historical changes to our supplier lead times at Anduril, how would you implement slowly changing dimensions (SCD) in your data model?

Use the supplied supplier and lead-time snapshot data to produce the historical records needed for a Type 2 dimension, including effective date ranges and the current-record indicator.

Output

  1. One row per supplier lead-time version, excluding unchanged snapshots.
  2. Columns: supplier_id, supplier_name, lead_time_days, effective_from, effective_to, and is_current.
  3. Sort by supplier_id, then effective_from ascending. The latest version for each supplier has a null effective_to.

Schema

suppliers
ColumnTypeDescription
supplier_idPKINTUnique supplier identifier
supplier_nameVARCHAR(120)Supplier name
supplier_lead_time_snapshots
ColumnTypeDescription
snapshot_idPKINTUnique snapshot identifier
supplier_idINTReferenced supplier
snapshot_dateDATEDate the lead time was observed
lead_time_daysINTObserved supplier lead time in days
Tablessupplierssupplier_lead_time_snapshots
Interviewer

Your question is Implementing SCD for Lead Times. 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.