Re: 1 foreign key to 2 different tables?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Ryan Riehle <rkr(at)buildways(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: 1 foreign key to 2 different tables?
Date: 2004-05-02 01:39:55
Message-ID: 20040502013955.GA29213@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, May 01, 2004 at 18:09:34 -0400,
Ryan Riehle <rkr(at)buildways(dot)com> wrote:
> For what I am reading now it looks like this is an opportunity to use CREATE
> ASSERTION, but this functionality appears to be unstable so far and is not
> recommended for production environments. Is this correct? Otherwise, can
> someone post an example of implementing a check constraint or trigger since
> I have not created a check onstraint that is above common complexity and and
> have never tried a trigger.

The simplest way to do this is probably be to use two separate fields
to make the references and make sure exactly one of them is nonnull.
You also might want to rethink your design. That you want to do this
suggests that there is something odd about the schema design you
have come up with.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mike McGavin 2004-05-02 03:53:36 Tracking structural changes from psql
Previous Message Ryan Riehle 2004-05-01 22:09:34 Re: 1 foreign key to 2 different tables?