X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 0C0FD9FB1C2 for ; Mon, 24 Jul 2006 05:59:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 59993-08 for ; Mon, 24 Jul 2006 08:59:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id C81D09FB1B7 for ; Mon, 24 Jul 2006 05:59:15 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by svr4.postgresql.org (Postfix) with ESMTP id E05D85AFB20 for ; Mon, 24 Jul 2006 08:59:14 +0000 (GMT) Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1G4wHL-0005Ch-00; Mon, 24 Jul 2006 09:59:07 +0100 Date: Mon, 24 Jul 2006 09:59:07 +0100 To: Bruno Wolff III , pgsql-sql@postgresql.org Subject: Re: Referential integrity (foreign keys) across multiple tables Message-ID: <20060724085907.GA19981@furbychan.cocan.org> References: <20060722133257.GA9785@furbychan.cocan.org> <20060723183237.GA22586@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060723183237.GA22586@wolff.to> User-Agent: Mutt/1.5.9i From: Richard Jones X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200607/292 X-Sequence-Number: 25866 On Sun, Jul 23, 2006 at 01:32:37PM -0500, Bruno Wolff III wrote: > On Sat, Jul 22, 2006 at 14:32:57 +0100, > Richard Jones wrote: > > > > Now I want to add a column to page_contents, say called link_name, > > which is going to reference the pages.url column for the particular > > host that this page belongs to. > > What are you trying to accomplish by this? Data integrity. > The information is available by doing a join. If you are trying to > simplify things for applications, you can probably do it with a view > or rules depending on whether you want to have an updatable view. If > you are denormalizing for performance and want constraints to > maintain consistancy, then you probably want to push the hostid down > to page_contents as well as the url. These could both be set with a > trigger. (I think a rule could be used as well.) So if I get this right, I should use a trigger to ensure that the old code causes the hostid field to be set in page_contents? Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com