Re: Shared Foreign Keys From Two Tables

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "Thomas T(dot) Thai" <tom(at)minnesota(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Shared Foreign Keys From Two Tables
Date: 2004-07-30 18:08:12
Message-ID: 20040730180812.GA16309@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jul 30, 2004 at 12:01:44 -0500,
"Thomas T. Thai" <tom(at)minnesota(dot)com> wrote:
>
> The above setup works. In table groupie_mod_pref, I needed mod_id to be
> a shared common foreign key in two other tables. Consequently in used
> two table constraints in groupie_mod_pref. However, I thought that was a
> waste of storage space having to repeat groupie_id and mod_id from
> groupie_mod. Is there anyway to keep the functionality like above, while
> using groupie_mod_id from groupie_mod in groupie_mod_pref in place of
> groupie_id and mod_id and still constrain mod_id to mod_pref table?

Not easily. (It should be possible to do with triggers.) What you could do
is use a compound primary key in groupie_mod and mod_pref get rid of the
(presumably) surrogate primary keys.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-07-30 18:35:18 Re: Backup questions
Previous Message Jason Tesser 2004-07-30 18:07:36 Re: Backup questions