Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
AVATAr
Forum Regular
Posts: 524 Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:
Post
by AVATAr » Wed Aug 28, 2002 10:59 am
Just a question of the primary key in a table,... what do you thik is best, use an autoincrement field or a timestamp?
Thanks
mikeq
Forum Regular
Posts: 512 Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland
Post
by mikeq » Wed Aug 28, 2002 12:47 pm
I would go with the autoincrement.
There is a very slim chance (very very slim) that 2 people may retrieve the same timestamp, dependent on when it is assigned.
A primary key can be anything, as long as it is unique.
AVATAr
Forum Regular
Posts: 524 Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:
Post
by AVATAr » Wed Aug 28, 2002 12:52 pm
i knew about that chance... but i thought that if i have to store the timestamp anyway... i could use it as primary key.
JPlush76
Forum Regular
Posts: 819 Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:
Post
by JPlush76 » Wed Aug 28, 2002 1:41 pm
definately autoincrement
if you have a timestamp field as your first record in the table it will be updated EVERYTIME that row is accessed, so your key would always be changing
AVATAr
Forum Regular
Posts: 524 Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:
Post
by AVATAr » Wed Aug 28, 2002 1:43 pm
good point ... but... if i insert a timestamp in a string field... or some...
however.. i see autoincrement is the best solution
thanks