Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f57LwhE23277 for ; Thu, 7 Jun 2001 17:58:43 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f57LhJH37180 for pgsql-sql@postgresql.org; Thu, 7 Jun 2001 17:43:19 -0400 (EDT) (envelope-from news) From: Dennis X-Newsgroups: comp.databases.postgresql.sql Subject: Forein Key Problem Date: Thu, 7 Jun 2001 15:43:18 -0600 Organization: ZServe Lines: 39 Message-ID: <9foshm$148o$2@news.tht.net> Reply-To: dennis@zserve.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: scrappy@hub.org User-Agent: KNode/0.4 To: pgsql-sql@postgresql.org X-Archive-Number: 200106/117 X-Sequence-Number: 3337 Is This s bug: create table A ( key varchar(20) not null primary key ); create table B ( id serial not null primary key, col1 varchar(20) not null, col2 varchar(20) not null ); alter table B create constraint fk_col1 foreign key ( col1 ) references A ( key ) on delete cascade on update cascade; alter table B create constraint fk_col2 foreign key ( col2 ) references A ( key ) on delete cascade on update cascade; SQL Creation and operation works fine. In the case that one row in table B where col1 = col2, if I update A.key, I'll get a referential integrity violation?? ie: ERROR: fk_col1 referential integrity violation - key referenced from B not found in A. Is there a way to make this type of constraint work with the update? If not, is there a way to create a constraint so that col1 != col2 is inforced? Thanks in advance.. Dennis