Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id B14A19FB1EA for ; Tue, 9 Jan 2007 10:40:16 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 96316-05 for ; Tue, 9 Jan 2007 10:40:02 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from druid.net (druid.net [66.96.28.249]) by postgresql.org (Postfix) with ESMTP id 47A1C9FB208 for ; Tue, 9 Jan 2007 10:40:02 -0400 (AST) Received: from dilbert.druid.net (H245.C18.B96.tor.eicat.ca [66.96.18.245]) by druid.net (Postfix) with SMTP id 56874B58B; Tue, 9 Jan 2007 09:39:48 -0500 (EST) Date: Tue, 9 Jan 2007 09:41:13 -0500 From: "D'Arcy J.M. Cain" To: Curtis Scheer Cc: pgsql-sql@postgresql.org, postgresql@aranya.com Subject: Re: Table relationships Message-Id: <20070109094113.064bae02.darcy@druid.net> In-Reply-To: <031936836C46D611BB1B00508BE7345D04DC1BB5@gatekeeper.daycos.com> References: <031936836C46D611BB1B00508BE7345D04DC1BB5@gatekeeper.daycos.com> X-Mailer: Sylpheed version 2.2.0 (GTK+ 2.8.12; i386-portbld-freebsd6.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/19 X-Sequence-Number: 27171 On Mon, 8 Jan 2007 17:07:56 -0600 Curtis Scheer wrote: > -> Is there a difference between an address for the customer detail and an > address for the customer? > > Not really an address is an address, it's a matter of specify an address for > the customer master record which basically represents an entire customer > while the customerdetail represents departments within that company that > might be at a different address then the company's main office for instance. Could be that you need another table. Sounds like you have something like; company <===> address <===> detail Now you just have to indicate which address is the primary or head office. You can do that with a bool in the address table. You can even add a unique, partial index to address to assure that you only have one head office per company. Another alternative is to add another table which just holds the address: company <===> department <===> detail ^ ^ | | \==> address <==/ Obviously the address attached to the company is the head office. For departments you can either duplicate the reference to the address table or have NULL indicate a default to the head office. There are many possibilities. Which one is best will depend on analysing your particular business model. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.