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 2F3F89FA2A7 for ; Sun, 23 Jul 2006 15:26:56 -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 01947-08 for ; Sun, 23 Jul 2006 18:26:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from wolff.to (wolff.to [66.93.197.194]) by postgresql.org (Postfix) with SMTP id 65D819FA1E2 for ; Sun, 23 Jul 2006 15:26:51 -0300 (ADT) Received: (qmail 26746 invoked by uid 500); 23 Jul 2006 18:32:37 -0000 Date: Sun, 23 Jul 2006 13:32:37 -0500 From: Bruno Wolff III To: Richard Jones Cc: pgsql-sql@postgresql.org Subject: Re: Referential integrity (foreign keys) across multiple tables Message-ID: <20060723183237.GA22586@wolff.to> Mail-Followup-To: Bruno Wolff III , Richard Jones , pgsql-sql@postgresql.org References: <20060722133257.GA9785@furbychan.cocan.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060722133257.GA9785@furbychan.cocan.org> User-Agent: Mutt/1.4.2.1i 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/291 X-Sequence-Number: 25865 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? 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.)