Re: IS it a good practice to use SERIAL as Primary Key?

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: John McCawley <nospam(at)hardgeus(dot)com>
Cc: Scott Ribe <scott_ribe(at)killerbytes(dot)com>, pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: IS it a good practice to use SERIAL as Primary Key?
Date: 2006-11-27 23:25:41
Message-ID: 1164669941.6398.28.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2006-11-27 at 17:09 -0600, John McCawley wrote:
> This list represents the most informed database admins I know, and while
> the conversation can easily devolve into minutae, I am genuinely
> interested in everyone's opinions on this subject. Primary keys are a
> pretty central aspect of database design, and most everyone on this list
> has unique experiences with the pros and cons of each approach...I'm
> pretty interested in the discussion.

Well sure, but the conversation was no longer productive. People were
getting stuck on what amounted to a very trivial example. There were
huge problems with that example and it in no way could represent an
legitimate use in production without a whole lot of caveats.

If we want to have a discussion about artificial versus natural keys,
rock on.. but the answer is simple:

A artificial does not protect against duplication.

That's it, in a nut shell. There is no argument there. That is why you
don't use artificial keys. That said... pretty much every table I create
will have an artificial key... because it makes managing data easy. An
example (to reuse the simple example):

users
=====
id serial unique,
first_name text,
last_name text,
primary key (first_name,last_name)

Yes there are problems with the above, namely you will likely have more
than one joshua drake.

Sincerely,

Joshua D. Drake

>
> Joshua D. Drake wrote:
>
> >Please... find something more productive to do.
> >
> >Sincerely,
> >
> >Joshua D. Drake
> >
> >
> >
> >
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2006-11-27 23:26:42 Re: Editing contrib modules which are loaded by default?
Previous Message Jim Nasby 2006-11-27 23:24:31 Re: IN clause