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 A01EA9DCA4F for ; Wed, 4 Jan 2006 23:12:20 -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 67244-05 for ; Wed, 4 Jan 2006 23:12:24 -0400 (AST) Received: from hub.org (hub.org [200.46.204.220]) by postgresql.org (Postfix) with ESMTP id A602E9DCA29 for ; Wed, 4 Jan 2006 23:12:18 -0400 (AST) Received: from localhost (unknown [200.46.204.144]) by hub.org (Postfix) with ESMTP id B31F662C8F2 for ; Wed, 4 Jan 2006 23:12:24 -0400 (AST) Received: from hub.org ([200.46.204.220]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66700-09; Wed, 4 Jan 2006 23:12:22 -0400 (AST) Received: from ganymede.hub.org (blk-222-82-85.eastlink.ca [24.222.82.85]) by hub.org (Postfix) with ESMTP id A670862C8EF; Wed, 4 Jan 2006 23:12:22 -0400 (AST) Received: by ganymede.hub.org (Postfix, from userid 1000) id 4DB3F45FC7; Wed, 4 Jan 2006 23:12:27 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 4855945D1C; Wed, 4 Jan 2006 23:12:27 -0400 (AST) Date: Wed, 4 Jan 2006 23:12:27 -0400 (AST) From: "Marc G. Fournier" X-X-Sender: scrappy@ganymede.hub.org To: Tom Lane cc: pgsql-sql@postgresql.org Subject: Re: FOREIGN KEYs ... I think ... In-Reply-To: <27177.1136426087@sss.pgh.pa.us> Message-ID: <20060104230722.N1088@ganymede.hub.org> References: <20060104213210.A1088@ganymede.hub.org> <27177.1136426087@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.946 required=5 tests=[AWL=0.467, DNS_FROM_RFC_ABUSE=0.479] X-Spam-Score: 0.946 X-Spam-Level: X-Archive-Number: 200601/20 X-Sequence-Number: 23809 On Wed, 4 Jan 2006, Tom Lane wrote: > "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. I may end up getting to that point ... > 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). 'k, where I'm getting lost here is how do I get status changed in _comments on UPDATE of incident_summary.id? There doesn't seem to be anything for ON UPDATE to 'run SQL query' or some such ... or I'm reading old docs :( This is the part that I'm having a bugger of a time wrapping my head around ... ---- Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664