0% found this document useful (0 votes)
27 views

SCD

The document discusses slow changing dimensions in data warehousing and ETL. It describes three types of slow changing dimensions and provides examples of how to model them using flags, versions, or dates to track historical changes to dimensions like customer, product, and time dimensions.

Uploaded by

PAVANN T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

SCD

The document discusses slow changing dimensions in data warehousing and ETL. It describes three types of slow changing dimensions and provides examples of how to model them using flags, versions, or dates to track historical changes to dimensions like customer, product, and time dimensions.

Uploaded by

PAVANN T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

SCD: Slowly Changing Dimension:

===============================
Dimension table: (PK+Attributes)

customer
product
account
user
employee
region
location
time
store
merchant

Type: 1 - No history will be maintained


Simple update

Type: 2 - History will be maintained


Row level history

Method - 1 - Flag
Method - 2 - Version
Method - 3 - Date

Type: 3 - Recent history will be maintained


Column level history

Surrogate Key:

create table S_customer_scd


(
Customer_id number(10) primary key,
First_name varchar2(30),
Mobile varchar2(30),
Address1 varchar2(30),
Zipcode number(6),
Country varchar2(30));

create table t_customer_scd_flag


(
Customer_key number(10) primary key,
Customer_id number(10),
First_name varchar2(30),
Mobile varchar2(30),
Address1 varchar2(30),
Zipcode number(6),
Country varchar2(30),
flag number(1));
create table t_customer_scd_version
(
Customer_key number(10) primary key,
Customer_id number(10),
First_name varchar2(30),
Mobile varchar2(30),
Address1 varchar2(30),
Zipcode number(6),
Country varchar2(30),
version number(4));

create table t_customer_scd_date


(
Customer_key number(10) primary key,
Customer_id number(10),
First_name varchar2(30),
Mobile varchar2(30),
Address1 varchar2(30),
Zipcode number(6),
Country varchar2(30),
eff_date date,
end_date date);

-----------------------------------------------------------------------------------
-------

select column_name from T_Customer_Version


where (cust_id,version) in (select cust_id,max(version) from
T_Customer_Version group by cust_id);

You might also like