advancedTop 15 Database Design Questions
Design a database that handles slowly changing dimensions (SCD Type 2) for customer data.
customers_history(id BIGSERIAL, customer_id INT, name, email, address, valid_from DATE, valid_to DATE NULLABLE, is_current BOOLEAN) On update: UPDATE old row: valid_to = TODAY, is_current = FALSE; INSERT new row: valid_from = TODAY, valid_to = NULL, is_current = TRUE Partial index on current records: CREATE INDEX ON customers_history(customer_id) WHERE is_current = TRUE Query current: WHERE is_cur
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
Design a database that handles slowly changing dimensions (SCD Type 2) for customer data.