X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 17FC7D1BA0A for ; Wed, 26 May 2004 10:59:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 75039-02 for ; Wed, 26 May 2004 10:59:39 -0300 (ADT) Received: from simmts12-srv.bellnexxia.net (simmts12.bellnexxia.net [206.47.199.141]) by svr1.postgresql.org (Postfix) with ESMTP id 1F898D1B176 for ; Wed, 26 May 2004 10:59:34 -0300 (ADT) Received: from localhost ([67.71.24.121]) by simmts12-srv.bellnexxia.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20040526135938.BNOY15788.simmts12-srv.bellnexxia.net@localhost>; Wed, 26 May 2004 09:59:38 -0400 Received: from sympatico.ca ([192.168.250.6]) by (8.11.6/8.11.6) with ESMTP id i4QDxbg13977; Wed, 26 May 2004 09:59:37 -0400 Message-ID: <40B4A2FD.8030004@sympatico.ca> Date: Wed, 26 May 2004 10:00:29 -0400 From: Jean-Luc Lachance User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andreas Cc: pgsql-sql@postgresql.org Subject: Re: Multitable uniqueness ? References: <40B40B4A.4050908@gmx.net> In-Reply-To: <40B40B4A.4050908@gmx.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/209 X-Sequence-Number: 17923 Do you really need MANY-TO-MANY between customers and projects? I can see customers owning many projects, but do you really have projects belonging to many customers? If not, fold cust_proj into projects. Otherwise, UNIQUE (cp_id, stall_no) on stalls should be enough. Andreas wrote: > Hi folks, > > Is there a way to have something like this : UNIQUE (table_1.id, > table_2.xxx) > > I got some tables that have a couple of foreign keys. Now I try to > minimize those relationships to clean up the mess. :-} > We do business fairs. (???) Like c-bit only a few magnitudes smaller. > So we have projects and rent stalls to customers. > > customers (c_id, ...) > projects (p_id,...) > > there is an relation cust_proj (cp_id, c_fk, p_fk, status_fk) > with a UNIQUE constraint (c_fk, p_fk) > > A customer can have several orders, contacts, ... tied to a project. > > Those look like this stalls (stall_id, cp_id, stall_no, ...) > o_id PRIMARY > cp_fk FOREIGN KEY that ties to custmer and project > > stall_no is a varchar > It should be unique within a project. > > Will I have to integrate the project.id into the stalls-table ? > > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings >