Re: [GENERAL] Foreign Key normalization question

2008-09-02 Thread Matthew Wilson
On Tue 02 Sep 2008 05:35:25 PM EDT, D. Dante Lorenso wrote: > You could add a trigger to your product_location table that just > double-checked the customers matched or prevents the insert/update. A > PL/PGSQL function like this might help: > > -- 8< 8< -- >

Re: [GENERAL] Foreign Key normalization question

2008-09-02 Thread D. Dante Lorenso
Matthew Wilson wrote: On Tue 02 Sep 2008 04:40:55 PM EDT, Scott Marlowe wrote: On Tue, Sep 2, 2008 at 2:35 PM, Matthew Wilson <[EMAIL PROTECTED]> wrote: On Tue 02 Sep 2008 04:19:41 PM EDT, Scott Marlowe wrote: If the two subordinate tables ALWAYS have to point to the same place, why two tables

Re: [GENERAL] Foreign Key normalization question

2008-09-02 Thread Roberts, Jon
, location_id int references location (id) ); Jon > -Original Message- > From: [EMAIL PROTECTED] [mailto:pgsql-general- > [EMAIL PROTECTED] On Behalf Of Matthew Wilson > Sent: Tuesday, September 02, 2008 3:35 PM > To: pgsql-general@postgresql.org > Subject: Re: [GENERAL] Foreign

Re: [GENERAL] Foreign Key normalization question

2008-09-02 Thread Matthew Wilson
On Tue 02 Sep 2008 04:40:55 PM EDT, Scott Marlowe wrote: > On Tue, Sep 2, 2008 at 2:35 PM, Matthew Wilson <[EMAIL PROTECTED]> wrote: >> On Tue 02 Sep 2008 04:19:41 PM EDT, Scott Marlowe wrote: >>> If the two subordinate tables ALWAYS have to point to the same place, >>> why two tables? Can't a cus

Re: [GENERAL] Foreign Key normalization question

2008-09-02 Thread Scott Marlowe
On Tue, Sep 2, 2008 at 2:35 PM, Matthew Wilson <[EMAIL PROTECTED]> wrote: > On Tue 02 Sep 2008 04:19:41 PM EDT, Scott Marlowe wrote: >> If the two subordinate tables ALWAYS have to point to the same place, >> why two tables? Can't a customer have > 1 location? I'm pretty sure >> IBM has more than

Re: [GENERAL] Foreign Key normalization question

2008-09-02 Thread Matthew Wilson
On Tue 02 Sep 2008 04:19:41 PM EDT, Scott Marlowe wrote: > If the two subordinate tables ALWAYS have to point to the same place, > why two tables? Can't a customer have > 1 location? I'm pretty sure > IBM has more than one corporate office you could ship things to. Yeah, so the idea is one custo

Re: [GENERAL] Foreign Key normalization question

2008-09-02 Thread Matthew Wilson
On Tue 02 Sep 2008 04:06:20 PM EDT, Martin Gainty wrote: > you can use setup a foreign key constraint in your create table so that col= > umn is only populated when > there is a value which syncs to the referenced value > http://www.postgresql.org/docs/7.4/interactive/sql-createtable.html I don't

Re: [GENERAL] Foreign Key normalization question

2008-09-02 Thread Scott Marlowe
On Tue, Sep 2, 2008 at 1:14 PM, Matthew Wilson <[EMAIL PROTECTED]> wrote: > I'm building an app that has a customers table, a locations table, a > products table, and a product_locations table. > > They make a diamond shape. > > The locations table and the products table each have a customer_id > c

Re: [GENERAL] Foreign Key normalization question

2008-09-02 Thread Martin Gainty
within this transmission. > To: pgsql-general@postgresql.org > From: [EMAIL PROTECTED] > Subject: [GENERAL] Foreign Key normalization question > Date: Tue, 2 Sep 2008 19:14:17 + > > I'm building an app that has a customers table, a locations table, a > products tabl

[GENERAL] Foreign Key normalization question

2008-09-02 Thread Matthew Wilson
I'm building an app that has a customers table, a locations table, a products table, and a product_locations table. They make a diamond shape. The locations table and the products table each have a customer_id column that links back to the customers table. Then the product_locations table table