Re: Multiple foreign keys on same field

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Ciprian Popovici <ciprian(at)zuavra(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Multiple foreign keys on same field
Date: 2004-12-14 05:32:46
Message-ID: 20041214053246.GB8082@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Dec 14, 2004 at 02:06:24 +0200,
Ciprian Popovici <ciprian(at)zuavra(dot)net> wrote:
> I'm in a situation where it would be useful to bind a field in a table via
> foreign keys to N other tables simultaneously. The table holds a common
> type of info which all those other tables use. The many tables refer to the
> common table by keeping references to its serial field.
>
> By doing this, I could ensure that when a row in any of the many tables is
> deleted or updated, the effect travels to the common table.
>
> So far, I've been successful in defining more than one foreign key on the
> same field in the lone table, tied to fields in different tables. (I half
> expected it not to work though).
>
> However, it seems that inserting values in the commons table is a
> showstopper: it expects that field value to exists not in only one, but in
> ALL bound tables simultaneously.

Are you sure you don't really want the foreign key relation to go in the
other direction?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2004-12-14 05:40:54 Re: Corrupt RTREE index
Previous Message Alex 2004-12-14 02:37:40 Help needed with QueryPlan