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 476DAD1E000 for ; Wed, 26 May 2004 00:13:45 -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 45018-01 for ; Wed, 26 May 2004 00:13:25 -0300 (ADT) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 76022D1E00C for ; Wed, 26 May 2004 00:13:23 -0300 (ADT) Received: (qmail 23428 invoked by uid 65534); 26 May 2004 03:13:21 -0000 Received: from p508BDE96.dip.t-dialin.net (EHLO [192.168.0.108]) (80.139.222.150) by mail.gmx.net (mp027) with SMTP; 26 May 2004 05:13:21 +0200 X-Authenticated: #14269776 Message-ID: <40B40B4A.4050908@gmx.net> Date: Wed, 26 May 2004 05:13:14 +0200 From: Andreas User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.7) Gecko/20040514 X-Accept-Language: de-de, en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Multitable uniqueness ? Content-Type: text/plain; charset=ISO-8859-1; 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/205 X-Sequence-Number: 17919 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 ?