X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 38FFF9FA0EC for ; Thu, 6 Jul 2006 15:39:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 09701-01 for ; Thu, 6 Jul 2006 15:39:21 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web33314.mail.mud.yahoo.com (web33314.mail.mud.yahoo.com [68.142.206.129]) by postgresql.org (Postfix) with SMTP id B178A9F94F3 for ; Thu, 6 Jul 2006 15:39:21 -0300 (ADT) Received: (qmail 46010 invoked by uid 60001); 6 Jul 2006 18:39:20 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=j8JvuHXr5BVYSTl9EfEp/Pu092R463v20uLjdF5xdftdEoARTZc9vWxUtdxOBf8mQS5IrbunY6OCRy5BiCUjj1RaqW2CKTQSsktlddN8B0WGmRKups4xgTUryIw8t9c9BNzK2siQ2B65DTXWxgg3DosETaVEqD6GXq/U0RMKxcE= ; Message-ID: <20060706183920.46008.qmail@web33314.mail.mud.yahoo.com> Received: from [12.9.179.126] by web33314.mail.mud.yahoo.com via HTTP; Thu, 06 Jul 2006 11:39:20 PDT Date: Thu, 6 Jul 2006 11:39:20 -0700 (PDT) From: Subject: Re: Alternative to serial primary key To: Aaron Bono Cc: pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/67 X-Sequence-Number: 25641 > On 7/6/06, David Clarke 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