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 00D959DCAAF for ; Wed, 7 Dec 2005 15:03:36 -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 99593-01 for ; Wed, 7 Dec 2005 15:03:36 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 9EE649DCAAE for ; Wed, 7 Dec 2005 15:03:34 -0400 (AST) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 8FE2542F3D6; Wed, 7 Dec 2005 18:56:53 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 8B76115EA4; Wed, 7 Dec 2005 18:57:07 +0000 (GMT) Message-ID: <43973083.3070803@archonet.com> Date: Wed, 07 Dec 2005 18:57:07 +0000 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051025) MIME-Version: 1.0 To: Jure Kodzoman Cc: pgsql-sql@postgresql.org Subject: Re: constrains problem... References: <1133959084.5964.6.camel@localhost.localdomain> In-Reply-To: <1133959084.5964.6.camel@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit 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/59 X-Sequence-Number: 23601 Jure Kodzoman wrote: > What i would like to do is create a trigger or a constraint which would > on delete of an entry from table1 also deleted all entries containing > code from > table1 in table_rel. When i try to put a constraint via PgAdmin3 it says > it can't do > it because 't1code' is not primary key or unique. > > I understand the error, but what i would like to know is how to delete > all fields from table_rel containing the 'table1' vaule being equal to > 'code' being deleted from table1. You put two foreign keys ON table_rel, referencing table1 and table2. Set both to delete on cascade and you're done. -- Richard Huxton Archonet Ltd