Loading data into Time Dimension
Moderators: chulett, rschirm, roy
Loading data into Time Dimension
Hi,
I have Oracle database.
How do I load data into time dimension.
The measures are day, month, qtr, year.
We have datastage 7.5
Thks
Ketfos
I have Oracle database.
How do I load data into time dimension.
The measures are day, month, qtr, year.
We have datastage 7.5
Thks
Ketfos
Hi,
I have transaction table with Policy Number, Location, Type, Premium Amount and Payment Date.
I want to create FACT and DIMESNION table.
I want to create a Fact Table which will have premium amount and corresponding Time Dimension table to analyze this fact on daily, monthly,quaterly and yearly basis.
Thanks
Ketfos
I have transaction table with Policy Number, Location, Type, Premium Amount and Payment Date.
I want to create FACT and DIMESNION table.
I want to create a Fact Table which will have premium amount and corresponding Time Dimension table to analyze this fact on daily, monthly,quaterly and yearly basis.
Thanks
Ketfos
Generation of the Time generation is very vital part in your Schema,
There are multiple ways to go ahead with that.
I would prefer doing all the calculations in an excel and loading into the table, rather than building a job to do that.
But if you want to go the datastage path -
Refer to the popular "TwoTechTips" documents, forgot which of the premium posters had compiled that.
There are multiple ways to go ahead with that.
I would prefer doing all the calculations in an excel and loading into the table, rather than building a job to do that.
But if you want to go the datastage path -
Refer to the popular "TwoTechTips" documents, forgot which of the premium posters had compiled that.
Narasimha Kade
Finding answers is simple, all you need to do is come up with the correct questions.
Finding answers is simple, all you need to do is come up with the correct questions.
-
- Charter Member
- Posts: 822
- Joined: Sat Sep 17, 2005 5:25 pm
- Location: USA
First decide the range of Dates you would like to have their and consider that as a Date_Key then easily you can break that into day,month,year and quarter using formulas.
Anyway Narasimha has been referring to this post
viewtopic.php?t=101775&highlight=twotechtips
Anyway Narasimha has been referring to this post
viewtopic.php?t=101775&highlight=twotechtips
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
Thomas Alva Edison(1847-1931)
Right Sam,us1aslam1us wrote:First decide the range of Dates you would like to have their and consider that as a Date_Key then easily you can break that into day,month,year and quarter using formulas.
Anyway Narasimha has been referring to this post
viewtopic.php?t=101775&highlight=twotechtips
How can I forget, It was courtesy, Craig and Kim. Thanks!
Narasimha Kade
Finding answers is simple, all you need to do is come up with the correct questions.
Finding answers is simple, all you need to do is come up with the correct questions.
-
- Premium Member
- Posts: 1255
- Joined: Wed Feb 02, 2005 11:54 am
- Location: United States of America
As an example of the structure of a time dimension. This is the one that is being used at my current site.
It can very well vary depending on your needs.
Code: Select all
Date_SK (PK, int, not null)
Date (varchar(8), null)
Day_Month (varchar(10), null)
Day_Number_Of_Month (int, null)
Is_Holiday (varchar(1), null)
Is_Weekend (varchar(1), null)
Long_Date (varchar(20), null)
Month_Begin_Date (datetime, null)
Month_End_Date (datetime, null)
Month_Long_Name (varchar(10), null)
Month_Number (int, null)
Month_Short_Name (varchar(5), null)
Quarter (int, null)
Quarter_Begin_Date (datetime, null)
Quarter_End_Date (datetime, null)
Short_Date (datetime, null)
Week_Begin_Date (datetime, null)
Week_End_Date (datetime, null)
Week_Number_Of_Month (smallint, null)
Week_Number_Of_Year (int, null)
Weekday_Long_Name (varchar(10), null)
Weekday_Number (int, null)
Weekday_Short_Name (varchar(5), null)
Year (int, null)
Year_Begin_Date (datetime, null)
Year_End_Date (datetime, null)
Year_Month_Name (varchar(10), null)
Year_Month_Number (varchar(10), null)
Year_Quarter (varchar(10), null)
Same_Day_Last_Year (datetime, null)
Same_Day_Next_Year (datetime, null)
Year_Week_Number (varchar(10), null)
Year_Week_Quarter (varchar(10), null)
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
And ALL of those fields except IsHoliday can be generated using DataStage functions - specifically Oconv(). You can even use a before-job subroutine to generate internal format dates in your desired range (job parameters) into a file, then process that file as your source of dates.
Holidays, of course, vary year by year; you can hard code the constant ones, but would need to invent some manual process for getting the variable ones into your system.
Holidays, of course, vary year by year; you can hard code the constant ones, but would need to invent some manual process for getting the variable ones into your system.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Hi,
Thanks, I have loaded data into the time dimension table (
Date_SK (PK, int, not null)
Date (varchar(8), null)
Month_Number(int,null)
Qtr_Number(int, null)
Year_Number(int,null)
I have transaction table Policy with following fields PolicyNumber, Premium_Amount, Region, payment_Date.
How do I load data into the PremiumFact table
(Date_SK (FK, int, not null)
Premium_Amount)
from transaction table Policy
The end result is to get premium_amount by day, month,qtr,year.
Ketfos
Thanks, I have loaded data into the time dimension table (
Date_SK (PK, int, not null)
Date (varchar(8), null)
Month_Number(int,null)
Qtr_Number(int, null)
Year_Number(int,null)
I have transaction table Policy with following fields PolicyNumber, Premium_Amount, Region, payment_Date.
How do I load data into the PremiumFact table
(Date_SK (FK, int, not null)
Premium_Amount)
from transaction table Policy
The end result is to get premium_amount by day, month,qtr,year.
Ketfos
-
- Premium Member
- Posts: 1255
- Joined: Wed Feb 02, 2005 11:54 am
- Location: United States of America
Code: Select all
time
|
|
|
|(Do a lookup on Policy.payment_Date = Time.Date and pull the Date_SK into PremiumFact )
|
|
|
|
Policy------------------->Transformer---------------->PremiumFact table
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
I would make your surrogate key a smart key like YYYYMMDD. This will save you a lot of work on lookups.
I wrote one of these in BASIC for Michael Hester. Maybe he will post it or allow me to post it if I can find it.
You usually have a couple of choices whn doing this in a routine. You can write it to a hashed file or sequential file. Next you need a job to push it to your table.
I wrote one of these in BASIC for Michael Hester. Maybe he will post it or allow me to post it if I can find it.
You usually have a couple of choices whn doing this in a routine. You can write it to a hashed file or sequential file. Next you need a job to push it to your table.
Mamu Kim
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You can load the hashed file from your Time dimension table, and create the smart key (if required) during that process. Basically, however, all you need is a two-column hashed file with the date as its key and the corresponding Time dimension surrogate key value as its other column.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.