| From: | Matthew Wilson <matt(at)tplus1(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Foreign Key normalization question |
| Date: | 2008-09-02 19:14:17 |
| Message-ID: | slrngbr449.gge.matt@sprout.tplus1.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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.
How do I do this?
Thanks in advance.
Matt
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Martin Gainty | 2008-09-02 20:06:20 | Re: Foreign Key normalization question |
| Previous Message | Richard Broersma | 2008-09-02 19:10:15 | Re: MERGE: performance advices |