Re: Alternative to serial primary key

From: <operationsengineer1(at)yahoo(dot)com>
To: Aaron Bono <postgresql(at)aranya(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Alternative to serial primary key
Date: 2006-07-06 18:39:20
Message-ID: 20060706183920.46008.qmail@web33314.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> On 7/6/06, David Clarke <pigwin32(at)gmail(dot)com> wrote:
> >
> > I posted a couple of weeks back a question
> regarding the use of a 100
> > char column as a primary key and the responses
> uniformily advised the
> > use of a serial column. My concern is that the key
> is effectively
> > abstract and I want to use the column as a foreign
> key in other
> > tables.
>
>
> I have a simple question... why do you want to use
> the column as a foreign
> key in other tables? If you use the serial column
> then all you need is a
> simple join to get the 100 char column out in your
> query. If you need to
> make things simpler, just create a view that does
> the join for you.
>
> Either there is some requirement here that I am not
> aware of or it sounds
> like you may be trying to use a sledge hammer on a
> nail.
>
> -Aaron

i agree. all my primary keys are abstract - even
though some don't have to be. iow, i'm comfortable
using serials as my primary key even when i don't
absolutely need to.

in any case, the primary key is typically used as a
unique identifer *and that's it*. the uniqueness
makes it ideal for another table to use it to link
related data.

it sounds like you want a unique identifier *plus
something else*. i'd argue that the "plus something
else" belongs in a separate column.

imho, your database life will be much easier and more
consistent.

good luck.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message operationsengineer1 2006-07-06 18:46:34 Re: Foreign Key: what value?
Previous Message Aaron Bono 2006-07-06 16:02:37 Re: Alternative to serial primary key