SCDs

Slowly Changing Dimensions ..

Workshop - Slowly Changing Dimensions Type 1 & 2

tr_scd

Placeholder for SCDs.

Create a new Transformation

Any one of these actions opens a new Transformation tab for you to begin designing your transformation.

  • By clicking File > New > Transformation

  • By using the CTRL-N hot key

SCD table

First step in these series of workshops, is to create a simple DIM_SCD table that has the required fields to illustrate a Type 1 change - just overwrite the value - and Type2 - where you need to record when any change in the value occurs.

  1. In your DB management tool, execute the following statement.

CREATE TABLE `DIM_SCD` (
  `TK` bigint(10) NOT NULL,
  `version` int(11) DEFAULT '0',
  `id` int(11) DEFAULT '0',
  `city` tinytext,
  `date_from` datetime DEFAULT NULL,
  `date_to` datetime DEFAULT NULL,
  `last_update` datetime DEFAULT NULL,
  PRIMARY KEY (`TK`),
  KEY `idx_DIM_SCD_lookup` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DIM_SCD

Lookup

This step is rarely used for lookups as specific steps exists; however, it does illustrate the database process of how referential integrity is maintained.

  1. Add ‘London’ to the Data Grid.

Data grid - lookup
Configure fields
  1. Ensure that the Dimension Lookup / Update is set to: Lookup Mode.

set lookup mode

Sets the step to Update Mode with lookup keys: id

There’s no point adding the LAST_UPDATE field as we're dealing with Type 1 changes.

  1. Click on the Fields tab.

Set city to string

RUN the Transformation

  1. Click the Run button in the Canvas Toolbar.

  2. Click on the Dimension lookup/update step and Preview the data.

Preview data

Why does London have a TK 0 and a value of NULL?

To maintain referential integrity, the record is assigned a TK 0, and as it doesn’t exist in the database, the value returned is NULL. As this is a lookup, no record is written to the database table.

Last updated