Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Create and Populate Time Dimension Expand / Collapse
Author
Message
Posted Saturday, September 22, 2007 10:53 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, October 27, 2005 11:47 PM
Points: 39, Visits: 1
Comments posted to this topic are about the item Create and Populate Time Dimension


Post #401437
Posted Monday, February 4, 2008 12:41 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, July 22, 2011 10:29 AM
Points: 4, Visits: 19
This can be hugely useful, although for accuracy's sake i'd suggest renaming it the "Date Dimension", since it doesn't really have anything to do with Time... A Time dimension would deal with Hours/Minutes/Seconds (and that's what i was looking for).

:)
Post #451303
Posted Tuesday, March 11, 2008 10:07 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, September 24, 2014 3:28 PM
Points: 227, Visits: 123
I was playign with this and noticed that the table population code misses setting the IsHoliday flag. Since the table has set that column to not null, the insert fails.



Post #467548
Posted Sunday, April 20, 2008 1:41 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, September 18, 2014 4:33 AM
Points: 23, Visits: 104
i would also probably drop the table rather than truncate in this instance. You would then get the same Identity value for each date each time you ran the code.

I have a question though, isnt there a performance impact of creating dim_time in this way with say a five year end date, as drop downs etc in front ends would be larger than required, and each date would create a null value in the fact table for every measure as the cube processes

Im thinking we should use code like the example in a slowly changing dimension with code in an if block

ie if Getdate() >= (select max(date) from DimTime) then
exec createDates 30(x num) days more data

an advantage to this is we would never have to revisit the time dimension unless there was a fundamental change like the Fiscal year dates changed and even this would just be a change to the sproc for future dates.



Post #487657
Posted Sunday, April 20, 2008 4:55 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 11:04 AM
Points: 35,546, Visits: 32,140
colin Robinson (4/20/2008)
i would also probably drop the table rather than truncate in this instance. You would then get the same Identity value for each date each time you ran the code.

I have a question though, isnt there a performance impact of creating dim_time in this way with say a five year end date, as drop downs etc in front ends would be larger than required, and each date would create a null value in the fact table for every measure as the cube processes

Im thinking we should use code like the example in a slowly changing dimension with code in an if block

ie if Getdate() >= (select max(date) from DimTime) then
exec createDates 30(x num) days more data

an advantage to this is we would never have to revisit the time dimension unless there was a fundamental change like the Fiscal year dates changed and even this would just be a change to the sproc for future dates.


Truncation of a table results in the IDENTITY column being reset to its original seed... there is no need to drop the table to achieve this result.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #487670
Posted Monday, April 21, 2008 6:05 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, September 18, 2014 4:33 AM
Points: 23, Visits: 104
Thanks for the pointer,

That would make a decent interview question. and it least a truncate means you can retain permissions etc.

Post #487876
Posted Saturday, August 9, 2008 12:07 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 4, 2008 10:48 PM
Points: 1, Visits: 1
sorry, 1'm from indonesian, little speak english :D

your source code, i'm excute values in populate Time Dimension Null ?

create dim time succes but value blank...

thanks....

Post #549701
Posted Wednesday, August 27, 2008 4:39 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, December 2, 2008 6:48 AM
Points: 3, Visits: 8
Hello. I'm also a newbie. You'll have to execute the stored procedure that comes with the code by typing 'exec sp_createTimeDim' and clicking the execute button.

You'll get an error because no value has been instantiated for the isholiday column, so go to the design view and set it to null. This will, at least for now, enable you to execute the code and have a feel of the results;)
Post #559481
Posted Wednesday, August 27, 2008 6:54 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 11:04 AM
Points: 35,546, Visits: 32,140
colin Robinson (4/21/2008)
Thanks for the pointer,

That would make a decent interview question. and it least a truncate means you can retain permissions etc.


Thanks for the feedback... Correct... no need to rebuild any permissions that way...

Not sure it makes such a great interview question... if too many people ask it, others hear of it and it becomes one of those things people simply memorize without ever having done it. I rather like weaving it into a simple multi-statement code example and ask them questions about what the intermediate and final result set's would be. Sure, memorization could still help there, but at least I know that they know when it applies and what it actually does and when.



--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #560053
Posted Wednesday, August 27, 2008 7:03 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 11:04 AM
Points: 35,546, Visits: 32,140
colin Robinson (4/20/2008)
i would also probably drop the table rather than truncate in this instance. You would then get the same Identity value for each date each time you ran the code.

I have a question though, isnt there a performance impact of creating dim_time in this way with say a five year end date, as drop downs etc in front ends would be larger than required, and each date would create a null value in the fact table for every measure as the cube processes

Im thinking we should use code like the example in a slowly changing dimension with code in an if block

ie if Getdate() >= (select max(date) from DimTime) then
exec createDates 30(x num) days more data

an advantage to this is we would never have to revisit the time dimension unless there was a fundamental change like the Fiscal year dates changed and even this would just be a change to the sproc for future dates.


Just as a suggestion...

It seems to me that a Calendar table of this nature (time dimension, whatever), should be made to go out to 01/01/2100 and that the GUI should have criteria in it to return the correct number of dates.

Heh... as a side bar, I have to ask why anyone would use a loop to creat such a simple table... then I saw the date this was published and that pretty well explains it. ;)


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #560056
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse