SpinTheMic
Pro

Explain it in 60 seconds

Surrogate keys in dbt

Data Engineering · dbt · Intermediate

How do you create surrogate keys in dbt and why?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • A surrogate key is a single generated key, often a hash of business key columns.
  • dbt_utils.generate_surrogate_key hashes columns and handles NULLs consistently.
  • Useful when the natural key is composite or comes from multiple sources.
  • Hash keys are deterministic, so the same input gives the same key in every run.
  • Test surrogate keys with unique and not_null.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics