From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jonathan Knopp <pgsql@delegated.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Way to stop recursion?
Date: Fri, 26 Nov 2004 16:31:11 -0500
Message-ID: <19345.1101504671@sss.pgh.pa.us> (raw)
In-Reply-To: <41A79A2A.6070606@delegated.net>
References: <41A79A2A.6070606@delegated.net>
Jonathan Knopp <pgsql@delegated.net> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgsql@delegated.net
Subject: Re: Way to stop recursion?
In-Reply-To: <19345.1101504671@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox