Re: Constraint to ensure value does NOT exist in another table?

From: "Igor Neyman" <ineyman(at)perceptron(dot)com>
To: "Mike Christensen" <mike(at)kitchenpc(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Constraint to ensure value does NOT exist in another table?
Date: 2011-06-16 13:21:20
Message-ID: F4C27E77F7A33E4CA98C19A9DC6722A207AB3A4A@EXCHANGE.corp.perceptron.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----Original Message-----
From: Mike Christensen [mailto:mike(at)kitchenpc(dot)com]
Sent: Thursday, June 16, 2011 1:05 AM
To: pgsql-general(at)postgresql(dot)org
Subject: Constraint to ensure value does NOT exist in another table?

I know I can setup a FK constraint to make sure Table1.ColA exists in
Table2.Key, however what if I want to do the reverse?

I want to ensure Table1.ColA does NOT exist in Table2.Key.. Can I do
this with any sort of CHECK constraint, trigger, custom function, etc?
Thanks!

Mike

Trigger (with corresponding trigger function) will definitely do the
job.

Regards,
Igor Neyman

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rick Harding 2011-06-16 13:29:49 Re: trouble building user defined agg function with plpython
Previous Message Torsten Zühlsdorff 2011-06-16 13:05:15 Re: You could be a PostgreSQL Patch Reviewer!