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 803FF9DCD68 for ; Wed, 7 Dec 2005 08:37:48 -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 18090-02 for ; Wed, 7 Dec 2005 08:37:50 -0400 (AST) X-Greylist: delayed 14:57:56.616719 by SQLgrey- Received: from avs4.arnes.si (avs4.arnes.si [193.2.1.77]) by postgresql.org (Postfix) with ESMTP id 7B59C9DCB87 for ; Wed, 7 Dec 2005 08:37:45 -0400 (AST) Received: from localhost (avs4.arnes.si [193.2.1.77]) by avs4.arnes.si (Postfix) with ESMTP id 930A72C3506 for ; Wed, 7 Dec 2005 13:37:47 +0100 (CET) Received: from avs4.arnes.si ([193.2.1.77]) by localhost (avs4.arnes.si [193.2.1.77]) (amavisd-new, port 10024) with ESMTP id 71813-02 for ; Wed, 7 Dec 2005 13:37:47 +0100 (CET) Received: from dhcp-212-235-229-194.sd.uni-lj.si (dhcp-212-235-229-194.sd.uni-lj.si [212.235.229.194]) by avs4.arnes.si (Postfix) with ESMTP id 4867D2C3545 for ; Wed, 7 Dec 2005 13:37:42 +0100 (CET) Subject: constrains problem... From: Jure Kodzoman To: pgsql-sql@postgresql.org Content-Type: text/plain Organization: Hrvatski planinarski savez Date: Wed, 07 Dec 2005 13:38:04 +0100 Message-Id: <1133959084.5964.6.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at arnes.si X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.666 required=5 tests=[AWL=0.666] X-Spam-Score: 0.666 X-Spam-Level: X-Archive-Number: 200512/55 X-Sequence-Number: 23597 Hy list, i would like to ask you for help. I have 3 tables. table1 has primary key 't1code' and table_rel is 'many to many' relation for table2. table2 primary key is 't2code' table_rel has two fields: 't1code' and 't2code', where both of them together make a primary key for the relation table. This is done so no double values exist. 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. Thanks a lot for your anwser! Yure