Received: from delhi1.mtnl.net.in (delhi1.mtnl.net.in [203.94.243.51]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eB8InjZ97780 for ; Fri, 8 Dec 2000 13:49:51 -0500 (EST) (envelope-from raju@ganwaar.com) Received: from ganwaar.com by delhi1.mtnl.net.in (8.9.1/1.1.20.3/07Jul00-0916AM) id AAA0000011778; Sat, 9 Dec 2000 00:16:54 +0530 (IST) Received: (from raju@localhost) by ganwaar.com (8.9.3/8.9.3) id AAA09926; Sat, 9 Dec 2000 00:19:34 +0530 From: Raju Mathur MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14897.11582.572215.341443@localhost.localdomain> Date: Sat, 9 Dec 2000 00:19:34 +0530 (IST) To: pgsql-admin@postgresql.org Subject: Foreign key split across two tables X-Mailer: VM 6.72 under 21.1 (patch 10) "Capitol Reef" XEmacs Lucid Reply-To: raju@linux-delhi.org X-Archive-Number: 200012/47 X-Sequence-Number: 239 Hi, Checked out the complete manual but I can't see a simple answer for this one: I have an invoice which I'm representing as two tables in the schema: the invoice header and the line items. One of the tables referred is the customer table, which uses customer number and location as the key. My problem is that the customer number is constant for the whole invoice and defined in the header, while the location varies by line item and is defined in the line item table; hence the foreign key (customer) is split across the invoice header and the invoice line item tables. Is there any way to validate that each line item contains a valid customer+location value? Last resorts would include defining a C/Perl/Tcl function, defining the customer code in the line item table or inheriting the line item table from the header table, but these solutions are unattractive due to either aesthetic or normalisation shortcomings. Regards, -- Raju -- Raju Mathur raju@kandalaya.org http://kandalaya.org/