Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have been a grateful member of this site for several years. I love this site and refer everyone to it!..."

Geography

Where in the world do Tek-Tips members come from?
ghowlett2020 (Programmer)
27 May 11 6:49
Hi,

Ok so I know generally its not good idea to have a DateTime column as your PK, however for my situation I believe it makes more sense than having a suggogate key in the Fact Table.

The reason are...

1) The data inserted to the fact table is always sequential. I.e. I would never insert date time value that is older than the last value already in Fact table. 2) The data time is not the only column of the PK (composite PK), The PK is of course itself and the dimension FK's surrogate key. 3) The way i be querying the data is nearly always based on time. 4) A surrogate key on the Fact table would tell me nothing about the row. Each row is already unique and to find that particular fact I would always filter on the Date time first and the values in the dimensions. 5) There is no seperate datetime dimension table. No requiremnet now of forseen to have named points in time etc.

Side notes - time will be in UTC and using SQL 2008 R2.

What im asking is giving the situation - what are the disadvantages to doing this? Will I come up against unforseen issues? Is this actaully a good thing to be doing when querying that data basck later?

Would like to know peoples view points on DataTime as first column of a composite PK.

Many Thanks

Gary
 
blom0344 (TechnicalUser)
27 May 11 16:42
I'm curious: what type of data are you storing and the granularity (minute, second?) Are you adding the datetime to enforce uniqueness?

Ties Blom
 
 

dkyrtata (Programmer)
27 May 11 21:19
I would be inclined to split your datetime field into two fields:
1) a date field declared as a NUMBER, formatted as YYYYMMDD (eq. 20111231)
2) a time field declared as a NUMBER, formatted as HH24MISS (eg. in range of 0-235959)

This way, your values can be used as surrogate keys, while retaining their appearance of dates and times.  Should you decide to add a date dimension table (and maybe a time dimension as well), you need not make any changes to your fact table. Only your queries would change to join to the date dimension.

 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close