On 2015-05-21 9:14 PM, Stephen Chrzanowski wrote:
> {{I just got a bounced message.. Reposting}}

Both of your attempts got through.  You got a bounce because you sent it to an 
invalid list address in addition to a valid one; one bounced the other didn't.

> I've been watching this thread from the beginning with great interest, and
> I still don't see the difference between using a UUID or an auto-inc
> integer as a PK at the very raw, basic level. The database will only see
> them as a string of bits or bytes and handle accordingly.  IMO, using UUID
> is an extra overhead for humans to deal with, which is going to cause more
> grief than necessary.

Personally I'm a strong advocate of using natural keys only wherever possible, 
which also has an effect on how you design your database.  When followed 
judiciously, it can lead to very well designed databases.

While table-specific surrogate keys like auto-inc or uuids make sense in some 
situations, they are greatly over used, and most of the time natural keys can 
be 
used instead.  I've seen many people use surrogate keys when there were 
perfectly suitable natural keys available instead.

As to auto-inc vs uuids, the main difference I see is that the former gives you 
tighter coupling to the database or between rows than is otherwise necessary.

To explain, when you use auto-inc, you are depending on the database to tell 
you 
what your row identifiers are, which gets more complicated if you're entering a 
set of related records where you want to use the same identifiers in multiple 
tables to indicate related records, eg parent-child.

When you don't use auto-inc, you can know in advance in the application before 
talking to the database what the complete values of all your new rows are, you 
know what values you are using to relate records to each other, you don't have 
to insert one row to know how to associate other rows.

Also when you auto-inc, values tend to be serial, so the order you insert 
records affects their final values, where when you don't auto-inc, your order 
of 
insertion has no impact on their final values (in the absense of triggers).

In that respect uuids can be better than auto-inc because you lose those 
coupling problems.  On the other hand uuids themselves should be used very 
sparingly, and I haven't really seen a reason to use them yet.

-- Darren Duncan

Reply via email to