pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Raju Mathur <raju@linux-delhi.org>
To: pgsql-admin@postgresql.org
Subject: Foreign key split across two tables
Date: Sat, 9 Dec 2000 00:19:34 +0530 (IST)
Message-ID: <14897.11582.572215.341443@localhost.localdomain> (raw)

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/



Message-ID: <14897.11582.572215.341443@localhost.localdomain>
Permalink:  ../14897.11582.572215.341443@localhost.localdomain/
Also on:    postgresql.org/message-id/14897.11582.572215.341443@localhost.localdomain

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: raju@linux-delhi.org
  Subject: Re: Foreign key split across two tables
  In-Reply-To: <14897.11582.572215.341443@localhost.localdomain>
  References: <14897.11582.572215.341443@localhost.localdomain>

* 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