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 5CAC49DC863 for ; Wed, 4 Jan 2006 23:31:38 -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 71615-04 for ; Wed, 4 Jan 2006 23:31:42 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp.gvtc.com (smtp.gvtc.com [216.177.160.80]) by postgresql.org (Postfix) with SMTP id D91569DC826 for ; Wed, 4 Jan 2006 23:31:35 -0400 (AST) Received: (qmail 22203 invoked from network); 5 Jan 2006 03:31:37 -0000 Received: from 12-181-68-5.block3.gvtc.com (HELO ?192.168.0.101?) (12.181.68.5) by smtp.gvtc.com with SMTP; 5 Jan 2006 03:31:37 -0000 Message-ID: <43BC9323.9000402@gvtc.com> Date: Wed, 04 Jan 2006 21:31:47 -0600 From: Jim Johannsen User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 CC: pgsql-sql@postgresql.org Subject: Re: FOREIGN KEYs ... I think ... References: <20060104213210.A1088@ganymede.hub.org> <27177.1136426087@sss.pgh.pa.us> <20060104230722.N1088@ganymede.hub.org> In-Reply-To: <20060104230722.N1088@ganymede.hub.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.189 required=5 tests=[MISSING_HEADERS=0.189] X-Spam-Score: 0.189 X-Spam-Level: X-Archive-Number: 200601/21 X-Sequence-Number: 23810 Marc Is the "assumption" that anytime there are comments the status changes? If I'm reading between the lines correctly, there could be a large number of comments before the status changes. So no need to change status until explicitly needed. If there is a specific "comment" that means a status change, you could code a trigger to check for the comment and then update the "status". I don't really like this solution but it could work. The front end/user should explicitly change the "status". Marc G. Fournier wrote: > 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 > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings > >