Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AE6A6476981 for ; Mon, 7 Oct 2002 20:03:43 -0400 (EDT) Received: from office.nextbus.com (ns.nextbus.com [64.164.28.194]) by postgresql.org (Postfix) with ESMTP id 9B77F476967 for ; Mon, 7 Oct 2002 20:03:42 -0400 (EDT) Received: from visor.corp.nextbus.com (visor.corp.nextbus.com [192.168.1.109]) by office.nextbus.com (Postfix) with ESMTP id 160764F87A for ; Mon, 7 Oct 2002 17:03:43 -0700 (PDT) Received: from localhost (laurette@localhost) by visor.corp.nextbus.com (8.11.2/8.8.7) with ESMTP id g9803it19679 for ; Mon, 7 Oct 2002 17:03:44 -0700 X-Authentication-Warning: visor.corp.nextbus.com: laurette owned process doing -bs Date: Mon, 7 Oct 2002 17:03:44 -0700 (PDT) From: Laurette Cisneros X-X-Sender: laurette@visor.corp.nextbus.com To: pgsql-sql@postgresql.org Subject: foreign key problem Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/97 X-Sequence-Number: 9815 I have two tables: create table table1 ( vers integer, table1_id text NOT NULL, desc text, PRIMARY KEY (rev, table1)id) ); create table table2 ( vers integer, othertble_id text NOT NULL, table1_id text, FOREIGN KEY (rev, othertable_id) REFERENCES othertable ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (rev, table1_id) REFERENCES table1 ON UPDATE CASCADE ON DELETE CASCADE, PRIMARY KEY (rev, othertable_id, table1_id) ); As you can see, table2 has a foreign key reference to table1 and also includes on delete cascade (and on update cascade). There has been a lot of activity in this database on these tables in particular in the last several days and somehow we've ended up with rows in table2 that have table1_ids that do not exist in table1. How is this possible? I've tried to reproduce this, but haven't been able to yet. This has happened to use several times. Thanks for any help, -- Laurette Cisneros The Database Group (510) 420-3137 NextBus Information Systems, Inc. www.nextbus.com ------------------------------ It's 10 o'clock... Do you know where your bus is?