Re: Shared Foreign Keys From Two Tables - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Shared Foreign Keys From Two Tables
Date
Msg-id 20040730180812.GA16309@wolff.to
Whole thread Raw
In response to Shared Foreign Keys From Two Tables  ("Thomas T. Thai" <tom@minnesota.com>)
List pgsql-general
On Fri, Jul 30, 2004 at 12:01:44 -0500,
  "Thomas T. Thai" <tom@minnesota.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.

pgsql-general by date:

Previous
From: Alvaro Herrera Munoz
Date:
Subject: Re: Backup questions
Next
From: "Jason Tesser"
Date:
Subject: Re: Backup questions