Re: inheritance and primary/foreign keys

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "Daniel J(dot) Kressin" <dkressin(at)globalcrossing(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: inheritance and primary/foreign keys
Date: 2001-03-07 23:54:02
Message-ID: Pine.BSF.4.21.0103071550120.75092-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 7 Mar 2001, Daniel J. Kressin wrote:

> Question 1: If table A has as its primary key "a_pk" and table B
> inherits table A, then table B also has as its primary key a_pk. Is
> that correct?

I don't believe so currently.

> Question 2: If I want table C to have a foreign key on both A and B, is
> the following syntax correct? (I'm using 7.0.3)
> CREATE TABLE c (
> c_fk correct_type REFERENCES a*(a_pk)
> );
> (The question is, Do I need the *?)
>
> Question 3: I understand that the default action on this will reverse in
> 7.1 (i.e. the default will then be to reference all tables unless ONLY
> is specified). Am I correct in assuming that the dump/restore (required
> for upgrading) will take care of this, or will I need to recreate table
> C manually removing the *?

You cannot safely reference tops of inheritance trees under 7.0 or 7.1 and
have it reference the trees.

Which reminds me, the fk constraint triggers should probably specify ONLY
on their queries or they'll fail strangely under 7.1.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Sawtell 2001-03-08 00:34:18 Re: Data types?
Previous Message Neil Conway 2001-03-07 23:39:30 Re: explain -> how to optimize?