From: | "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | "Matthew Wilson" <matt(at)tplus1(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Foreign Key normalization question |
Date: | 2008-09-02 20:19:41 |
Message-ID: | dcc563d10809021319w67af0523ndc7732e0b450617f@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Sep 2, 2008 at 1:14 PM, Matthew Wilson <matt(at)tplus1(dot)com> 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
> column that links back to the customers table.
>
> Then the product_locations table table has just two columns: a
> location_id column and a product_id column, each linking back to the
> appropriate table.
>
> I want to write a constraint or a trigger or something else that makes
> sure that before a (location_id, product_id) tuple is inserted into the
> product_locations table, the system verifies that the product links to
> the same customer as the location.
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Matthew Wilson | 2008-09-02 20:20:25 | Re: Foreign Key normalization question |
Previous Message | Martin Gainty | 2008-09-02 20:06:20 | Re: Foreign Key normalization question |