SpinTheMic
Pro

Data modeling · Intermediate

Explain the types of slowly changing dimensions (SCD).

By Anurag Pandey, Lead Data Engineer ·

The short answer

Type 0 never changes, Type 1 overwrites, Type 2 adds a new row per change with effective dates and a current flag, Type 3 keeps the previous value in an extra column, and Type 6 adds Type 1 current-value columns to a Type 2 dimension. Type 2 is the usual choice when you need history.

Practice this out loud

Opens this question on SpinTheMic. Start without signing up; sign in free for an AI report card.

Say it like this

About 60 seconds out loud. Use it as a model, then put it in your own words.

Slowly changing dimensions are about what happens when a descriptive attribute changes, like a customer moving city. Type 0 keeps the original value and never changes it. Type 1 overwrites the old value, so history is lost, which is fine for fixing typos. Type 2 keeps full history: I close the current row by setting its end date, and insert a new row with a new surrogate key, a start date and a current flag. Facts recorded before the move still point at the old row, so reports show the city at the time of the sale. Type 3 adds a column for the previous value and overwrites the main one, so it only keeps one step of history. Type 6 builds on Type 2: alongside the history rows, a current-value column is overwritten on every row for that customer. In practice, I choose per attribute, not per table.

What interviewers look for

  • You explain Type 2 step by step: close the old row, insert the new one.
  • You mention the surrogate key and why facts keep pointing at the old version.
  • You choose the type per attribute based on whether history matters.

Common mistakes

  • Reusing the natural key as the only key in a Type 2 dimension.
  • Forgetting the current flag or end date, which makes 'current' queries slow and error-prone.
  • Using Type 2 for every column, which multiplies rows for changes nobody reports on.

Follow-up questions to expect

  1. 1How would you implement SCD Type 2 with a MERGE statement?
  2. 2How do you handle a fact that arrives before its dimension row?
  3. 3How would you detect which rows changed in a large source table?
Practice this out loud

Opens this question on SpinTheMic. Start without signing up; sign in free for an AI report card.

Checked against

All interview question guides