Prefer using GUID to Autonumber keys for pk?

Posts   
 
    
Gabor
User
Posts: 97
Joined: 29-Jan-2005
# Posted on: 07-Jan-2006 10:08:44   

Hi,

What is the preferred method: using the GUID or Autonumber field for the primary key?

If I use the autonumber fields in the database, I can save one to many related tables without setting the pk values on the client, but when I use the GUID, I have to set the keys before the save, if I well understand.

Thank You for the explanation.

Gabor

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 07-Jan-2006 18:36:02   

Gabor wrote:

Hi,

What is the preferred method: using the GUID or Autonumber field for the primary key?

If I use the autonumber fields in the database, I can save one to many related tables without setting the pk values on the client, but when I use the GUID, I have to set the keys before the save, if I well understand.

Thank You for the explanation.

Gabor

My take on this is that it is business driven.

For example, in a shopping catalogue application, you would probably want your invoice numbers to be unique and generated in acending order...ideal to use as PK (Autonumber)..GUID would not be ideal in this case.

I personally have not use GUID as PK...only used them as an attribute to compare for to check for any updates to rows in a distributed application where there is a need for disconnected datasets for example.

Hope this helps.