X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 021209DC81E for ; Wed, 14 Dec 2005 06:22:57 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27420-09 for ; Wed, 14 Dec 2005 06:22:59 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp3.libero.it (smtp3.libero.it [193.70.192.127]) by postgresql.org (Postfix) with ESMTP id C7F329DC810 for ; Wed, 14 Dec 2005 06:22:55 -0400 (AST) Received: from localhost (172.16.1.83) by smtp3.libero.it (7.0.027-DD01) id 439D911000309C44 for pgsql-sql@postgresql.org; Wed, 14 Dec 2005 11:22:57 +0100 Received: from smtp20.libero.it ([172.16.1.77]) by localhost (asav4.libero.it [193.70.192.153]) (amavisd-new, port 10024) with ESMTP id 25988-05-2 for ; Wed, 14 Dec 2005 11:22:56 +0100 (CET) Received: from [172.16.0.5] (ppp-103-202.24-151.libero.it [151.24.202.103]) by smtp20.libero.it (Postfix) with ESMTP id 75BA5507AB for ; Wed, 14 Dec 2005 11:22:56 +0100 (MET) Message-ID: <439FF2E9.5040405@moonwatcher.it> Date: Wed, 14 Dec 2005 11:24:41 +0100 From: Gianluca Riccardi User-Agent: Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.7.8) Gecko/20050927 Debian/1.7.8-1sarge3 X-Accept-Language: it MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: DB design and foreign keys References: <439F0FE8.1050503@moonwatcher.it> <8787.1134498689@sss.pgh.pa.us> In-Reply-To: <8787.1134498689@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Scanned: with antispam and antivirus automated system at libero.it X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200512/113 X-Sequence-Number: 23655 [cut] > order_code is not by itself unique --- SERIAL doesn't guarantee that. > > that was my misunderstanding, i thought (misunderstood) that 'serial' implied 'unique' > I'm not sure why you are declaring the primary key of orders as being > the combination of *two* serial columns, i thought it was good design choice and even needed for foreign keys referencing on them > but if that's what you really > need > i'm not shure about that > and you also want to be able to reference a row by just one of > them, you'll need to apply a separate unique constraint to just the > order_code column. > > sorry, i'm afraid i didn't understand: are you suggesting to apply the constraint in case the primary key is kept on the combination of the two serial columns? or to remove the primary key of the two serial columns? > regards, tom lane > > thanks a lot for your kind response, best regards, Gianluca Riccardi