From: | Martin Gainty <mgainty(at)hotmail(dot)com> |
---|---|
To: | Matthew Wilson <matt(at)tplus1(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Foreign Key normalization question |
Date: | 2008-09-02 20:06:20 |
Message-ID: | BLU142-W340087D83CBB9A7BFB47FAAE5F0@phx.gbl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
you can use setup a foreign key constraint in your create table so that column 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
Martin
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.
> To: pgsql-general(at)postgresql(dot)org
> From: matt(at)tplus1(dot)com
> Subject: [GENERAL] Foreign Key normalization question
> Date: Tue, 2 Sep 2008 19:14:17 +0000
>
> 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
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
_________________________________________________________________
Get thousands of games on your PC, your mobile phone, and the web with Windows®.
http://clk.atdmt.com/MRT/go/108588800/direct/01/
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2008-09-02 20:19:41 | Re: Foreign Key normalization question |
Previous Message | Matthew Wilson | 2008-09-02 19:14:17 | Foreign Key normalization question |