**Architectural Logic**: SCD implementation depends on type; MERGE is the workhorse for atomicity. **SCD1**: UPDATE dim SET col = new_val WHERE key = X. **SCD2**: INSERT new row with effective_from; UPDATE current row's effective_to; set current_flag. **SCD3**: Add prev_col; on...
This easy-level SQL question appears frequently in data engineering interviews at companies like BCG. While less common, it tests deeper understanding that distinguishes strong candidates. Mastering the underlying concepts (etl) will help you answer variations of this question confidently.
Start by clearly defining the core concept being asked about. Interviewers want to see that you understand the fundamentals before diving into implementation details. Structure your answer with a definition, then explain the practical application with a concise example.
Architectural Logic: SCD implementation depends on type; MERGE is the workhorse for atomicity. SCD1: UPDATE dim SET col = new_val WHERE key = X. SCD2: INSERT new row with effective_from; UPDATE current row's effective_to; set current_flag. SCD3: Add prev_col; on change, shift current→prev. ETL Flow: (1) Extract changed records. (2) Lookup dimension. (3) Apply SCD logic (MERGE or INSERT/UPDATE). (4) Generate surrogate keys. Hash Comparison: For Type 2, hash attributes to detect change. Scalability: Use staging for change detection; batch MERGE. Cost: SCD2 increases row count; plan for history growth. Best Practice: Audit columns (created_at, updated_by); handle late-arriving dimensions.
This answer is partially locked
Unlock the full expert answer with code examples and trade-offs
Practice real interviews with AI feedback, track progress, and get interview-ready faster.
Pro starts at $24/mo - cancel anytime
Get the most asked SQL questions with expert answers. Instant download.
No spam. Unsubscribe anytime.
Paste your answer and get instant AI feedback with a FAANG-level improved version.
Analyze My Answer — FreeAccording to DataEngPrep.tech, this is one of the most frequently asked SQL interview questions, reported at 1 company. DataEngPrep.tech maintains a curated database of 1,863+ real data engineering interview questions across 7 categories, verified by industry professionals.