Re: [GENERAL] Sufficient Primary Key?

From: lynch(at)lscorp(dot)com (Richard Lynch)
To: Dan Delaney <dionysos(at)dionysia(dot)org>, PostgreSQL General List <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] Sufficient Primary Key?
Date: 1998-07-24 19:50:33
Message-ID: v02140b1ab1de4337210b@[207.152.64.133]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 11:06 AM 7/24/98, Dan Delaney wrote:
>Hello all.
> I'm working on a library catalog and trying to decide what to use
>for the primary key for the authors. Do you think that the first
>three letters of first and last name with the birth year would be
>sufficient (e.g., Alan Watts would be ALAWAT1915). So, essentially,
>do you think there there would ever be two authors with the same
>first and last name AND the same birth year? I really don't want to
>inject the middle name into there because I can't find the middle
>name (or even middle initial) of most authors!

My personal preference is *always* for an integer primary key, which has no
contextual meaningful connection whatsoever with the actual data.

In this particular instance, since you clearly are unsure that you can ever
guarantee uniqueness, there shouldn't even be a question about it: Use an
auto-incrementing integer.

create sequence authorId;

create table authors(
Id int4 unique not null default nextval('authorId'),
.
.
.
);

--
--
-- "TANSTAAFL" Rich lynch(at)lscorp(dot)com

Browse pgsql-general by date

  From Date Subject
Next Message Richard Lynch 1998-07-24 19:50:34 Re: [GENERAL] Re: [HACKERS] [Fwd: SGVLLUG Oracle and Informix on Linux]
Previous Message Byron Nikolaidis 1998-07-24 19:43:33 Re: [GENERAL] Re: [INTERFACES] ODBC Driver -- Access Order By problem solved!!!