Re: Foreign Key normalization question - Mailing list pgsql-general

From Martin Gainty
Subject Re: Foreign Key normalization question
Date
Msg-id BLU142-W340087D83CBB9A7BFB47FAAE5F0@phx.gbl
Whole thread Raw
In response to Foreign Key normalization question  (Matthew Wilson <matt@tplus1.com>)
List 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@postgresql.org
> From: matt@tplus1.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@postgresql.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®. Game with Windows

pgsql-general by date:

Previous
From: Matthew Wilson
Date:
Subject: Foreign Key normalization question
Next
From: "Scott Marlowe"
Date:
Subject: Re: Foreign Key normalization question