Você está na página 1de 3

url: http://datawarehouse.ittoolbox.

com/groups/technical-functional/informatica-
l/how-to-maintain-only-1-year-historical-data-in-dimension-from-current-date-907
743
How to maintain only 1 year historical data in dimension from current date
==========================================================================

Asked by rkashyap | posted Jan 23, 2006 | Replies (4)


0
Please Sign-in or Register to vote
I Think Below Solution should work fine ...try it...
solution
----------
note: we need to maintain few tables
assumption :
today is 01-feb-2005
history (dimension table) : maitains data from 01-feb-2005
to 31-jan-2006
current_day_data (table having structure similar to history)
: maintains data of 01-feb-2006
last_day_data (table having structure similar to history) :
maintains data of 01-feb-2005
archieve (table having structure similar to history) :
maintains data of 01-jan-2001 to 31-jan-2005
note : history table should be partitioned on day level.
(as of 01-feb-2005)
last_day_data current_day_data history
archieve
01-feb-2005 01-feb-2006 02-feb-2005 to 31-jan-2006
01-jan-2001 to 31-jan-2005

note : let say now we have to load 02feb2006 data


---------------
step1) insert data from last_day_data table to archieve ie data of
01-feb-2005
------
last_day_data current_day_data history
archieve
01-feb-2005 01-feb-2006 01-feb-2005 to 31-jan-2006
01-jan-2001 to 01-feb-2005
step2)
------
delete all data from last_day_data or truncate this table (will be
faster).
last_day_data current_day_data history
archieve
01-feb-2006 01-feb-2005 to 31-jan-2006
01-jan-2001 to 01-feb-2005
step3)
-------
insert data from current_day_data to history
last_day_data current_day_data history
archieve
02-feb-2006 02-feb-2005 to 01-feb-2006
01-jan-2001 to 01-feb-2005

step4)
-------
delete all data from current_day_data or truncate this table (will be
faster).
last_day_data current_day_data history
archieve
02-feb-2005 to 01-feb-2006
01-jan-2001 to 01-feb-2005

step5)
-------
load today's data ie 02-feb-2005 to current_day_data
last_day_data current_day_data history
archieve
02-feb-2006 02-feb-2005 to 01-feb-2006
01-jan-2001 to 01-feb-2005

step6)
-------
insert data of minimum date from history ie 02-feb-2005 to last_day_data

last_day_data current_day_data history


archieve
02-feb-2005 02-feb-2006 02-feb-2005 to 01-feb-2006
01-jan-2001 to 01-feb-2005

step7)
-------
delete minimum date record from history ie of 02-feb-2005 or drop the
partition having records of 02-feb-2005, which will be faster.
last_day_data current_day_data history
archieve
02-feb-2005 02-feb-2006 03-feb-2005 to 01-feb-2006
01-jan-2001 to 01-feb-2005

note : to use history table (dimension) for lookup, you have to create
view having following query
create view history_view as
select * from history
union all
select * from last_day_data
union all
select * from current_day_data

How to maintain only 1 year historical data in dimension from current date
==========================================================================
Asked by rama_krishna | posted Jan 24, 2006 | Replies (4)
0
Please Sign-in or Register to vote
Hi Shashi,
I am not sure which part is right!
But it can be achived in Informatica easilly.
I assume that you have two tables an History and a current dimension table to st
ore one year data.
I believe you already have an interface to load this Dimension table.
Assuming that Oracle is DB
1. To store data in History/archive table :
Select records from current Dimension table use ADD_MONTHS ('01-JAN-2006', -12).
Insert these records to History table.
2. remove records from Dimension table :
It should delete records less than ADD_MONTHS ('01-JAN-2006', -12).
Both of theese queries can be written in Post session SQL of the interface to lo
ad dimension table.
You can replace '01-JAN-2006' with sysdate or the any required date.
Regards,
Ramakrishna

Você também pode gostar