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 32DDE9DC9A3 for ; Wed, 14 Dec 2005 06:23:10 -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 29743-07 for ; Wed, 14 Dec 2005 06:23:11 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp6.libero.it (smtp6.libero.it [193.70.192.59]) by postgresql.org (Postfix) with ESMTP id C5F249DC810 for ; Wed, 14 Dec 2005 06:23:07 -0400 (AST) Received: from localhost (172.16.1.84) by smtp6.libero.it (7.0.027-DD01) id 439D919300327DB5 for pgsql-sql@postgresql.org; Wed, 14 Dec 2005 11:23:09 +0100 Received: from smtp0.libero.it ([172.16.1.77]) by localhost (asav5.libero.it [193.70.192.154]) (amavisd-new, port 10024) with ESMTP id 17594-07 for ; Wed, 14 Dec 2005 11:23:08 +0100 (CET) Received: from [172.16.0.5] (ppp-103-202.24-151.libero.it [151.24.202.103]) by smtp0.libero.it (Postfix) with ESMTP id C48833338E6 for ; Wed, 14 Dec 2005 11:23:07 +0100 (MET) Message-ID: <439FF2F9.4090809@moonwatcher.it> Date: Wed, 14 Dec 2005 11:24:57 +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> <439F137A.6010504@hardgeus.com> In-Reply-To: <439F137A.6010504@hardgeus.com> 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/114 X-Sequence-Number: 23656 John McCawley wrote: > Table orders defines the column order_code as a serial, which simple > makes a trigger which gives a new value to the column on insert. Note > that there is NO guarantee that ths column will be unique. You can > manually update the value to whatever you want. If you wish this > column to be unique, you must specify it on creation, or later do an > alter table add constraint to the column. > > A foreign key requires that the referenced column be unique (DB > enforced, not just coincidentally unique), and that' s why your table > creation is failing. [cut] that was my misunderstanding thanks for your reply, Gianluca Riccardi