Re: oid's and primary keys on insert

From: Joe Conway <mail(at)joeconway(dot)com>
To: Rob Brown-Bayliss <rob(at)zoism(dot)org>
Cc: Andrew Sullivan <andrew(at)libertyrms(dot)info>, PostgreSQL General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: oid's and primary keys on insert
Date: 2002-08-10 03:23:54
Message-ID: 3D54874A.8000100@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rob Brown-Bayliss wrote:
>>Why don't you use a sequence at each site and a "site id" field?
>>Then put a unique index on the site id + the sequence. You'd get
>>something like
>>
>> |site_id|trans_id|
>> ------------------
>> | 46 | 23456 |
>>
>>Also makes it easier to get "all transactions from site 46". You can
>>even set each site's site_id field to the appropriate default, if you
>>want, so that you don't have to handle it in your code.
>
>
> I started out that way, but thought the whole select and update thing
> would get messy, like select blah from wah where site_id = 43 and
> trans_id = 5345 rather than a single where pkey = 43-5345
>
> Thats realy the only reason I didn't do that. Not realy a goot reason
> at that...
>

I had the exact same experience. Having a 2 column primary key on every
table (and hence for every foreign key as well) gets unmanageable pretty
quickly.

Joe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Brown-Bayliss 2002-08-10 03:33:52 Re: oid's and primary keys on insert
Previous Message Rob Brown-Bayliss 2002-08-10 03:03:36 Re: oid's and primary keys on insert