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 CF6969DCB0F; Wed, 4 Jan 2006 21:54:45 -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 50732-03; Wed, 4 Jan 2006 21:54:49 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 6AB4A9DCB0D; Wed, 4 Jan 2006 21:54:43 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k051slZX027178; Wed, 4 Jan 2006 20:54:47 -0500 (EST) To: "Marc G. Fournier" cc: pgsql-sql@postgresql.org Subject: Re: FOREIGN KEYs ... I think ... In-reply-to: <20060104213210.A1088@ganymede.hub.org> References: <20060104213210.A1088@ganymede.hub.org> Comments: In-reply-to "Marc G. Fournier" message dated "Wed, 04 Jan 2006 21:49:52 -0400" Date: Wed, 04 Jan 2006 20:54:47 -0500 Message-ID: <27177.1136426087@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.068 required=5 tests=[AWL=0.068] X-Spam-Score: 0.068 X-Spam-Level: X-Archive-Number: 200601/19 X-Sequence-Number: 23808 "Marc G. Fournier" writes: > Now, what I want to do is add a FOREIGN KEY (again, I think) that when > incident_summary.status is changed (either closed, or reopened), the > associated records in incident_comments are changed to the same state ... Why not just get rid of the status column in incident_comments, and treat incident_summary.status as the sole copy of the state? When you need to get to it from incident_comments, you do a join. The foreign key you really ought to have here is from incident_comments.incident_id to incident_summary.id (assuming that I've understood your schema correctly). regards, tom lane