X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 56F4B3A4B19 for ; Fri, 26 Nov 2004 21:31:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45592-09 for ; Fri, 26 Nov 2004 21:31:15 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id B39FE3A4B09 for ; Fri, 26 Nov 2004 21:31:15 +0000 (GMT) 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 iAQLVBES019346; Fri, 26 Nov 2004 16:31:12 -0500 (EST) To: Jonathan Knopp Cc: pgsql-sql@postgresql.org Subject: Re: Way to stop recursion? In-reply-to: <41A79A2A.6070606@delegated.net> References: <41A79A2A.6070606@delegated.net> Comments: In-reply-to Jonathan Knopp message dated "Fri, 26 Nov 2004 13:03:38 -0800" Date: Fri, 26 Nov 2004 16:31:11 -0500 Message-ID: <19345.1101504671@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/268 X-Sequence-Number: 19586 Jonathan Knopp writes: > CREATE TABLE parent (id INT, cola CHAR(1), common CHAR(1)); > CREATE TABLE child (id INT, parent_id INT, cola(1), common(1)); > What I need, is when "common" is changed for a parent, then that new > value is reflected in "common" for all the children, ie: > ... > Problem is, when "common" is changed for a child, I need the parent and > all siblings to reflect that value too, ie: Seems to me that your real problem is a bogus database layout. If there should only be one "common" value for a parent and children, then only store one value ... that is, "common" should exist only in the parent. You can if you like make a view that emulates the appearance of a child table with a common column, viz create view childview as select child.*, parent.common from child, parent where parent_id = parent.id; and it would even be possible to make a rule that allows updating this view. regards, tom lane