Primary key Identificator on a table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Primary key Identificator on a table

Post by AVATAr »

Just a question of the primary key in a table,... what do you thik is best, use an autoincrement field or a timestamp?

Thanks
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

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.
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

thxs

Post by AVATAr »

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 »

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
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

great

Post by AVATAr »

good point ... but... if i insert a timestamp in a string field... or some...

however.. i see autoincrement is the best solution

thanks
Post Reply