If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Date primary key question!!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-21-07, 19:03
kjgreen kjgreen is offline
Registered User
 
Join Date: Apr 2007
Posts: 1
Date primary key question!!

I currently run a website that has different content each day. The content is saved in the database and the primary key is the date. I get the system date from the server and query for todays conent with that date variable. Currently the date field is a primary key and I chose to keep the field int(6) so the format is mmddyy. So I have one question:

1)Should I change my date field to be of date type instead of int? The reason I chose int is because I thought it would make the database faster.


I know some may say this won't make a difference, but this is for a class and I'm wanting the best choice for this date primary key type. I will be presentint this site to my teachers and don't want them to question why I chose int type instead of date if it doesn't make since.
Reply With Quote
  #2 (permalink)  
Old 04-21-07, 19:15
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
my money is on there being a high probability -- real soon -- of wanting to store more than one content per day

i think date is the wrong primary key

and yes, DATE is better than INTEGER for a date key
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-23-07, 05:07
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
I would agree with Rudy on this. Date should almost NEVER be a primary key, purely because it is usually a supplimentary field and often occurs more than once. Use a nice auto incrementing id
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On