Re: 1 foreign key to 2 different tables? - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: 1 foreign key to 2 different tables?
Date
Msg-id 20040502141648.GA5848@wolff.to
Whole thread Raw
In response to Re: 1 foreign key to 2 different tables?  ("Ryan Riehle" <rkr@buildways.com>)
List pgsql-general
On Sun, May 02, 2004 at 03:51:44 -0400,
  Ryan Riehle <rkr@buildways.com> wrote:
> Thanks for your input. Yes, there is a lot more to this part of the schema.
> The current stucture makes the most sense to us so far, after lots of
> thinking.  If you are interested I can offer you more details about the
> structure, but for now I am looking for how to implement this type of
> constraint with a trigger or another method - if there is a better way.

So far I haven't seen a good case for why there needs to only be one
pointer instead of two. When you are doing joins you are going to know
which one you want to join on. They are internal keys so you shouldn't
need to print them out directly. If you want to display something that
comes out of one joined table or the other, you are going to have to
join both a and b to c using some sort of outer joins. You can use
coalesce to get the information form the appropiate joined table.
You will still have to do things like this even if you share the pointer
field c, but it will be easier to set up the constraints if there are
two separate fields.

pgsql-general by date:

Previous
From: "Ryan Riehle"
Date:
Subject: Re: 1 foreign key to 2 different tables?
Next
From: Bill Moran
Date:
Subject: Re: Anyone interested in a Pittsburgh-area Postgres users'