Re: Foreign Key to Inherited table - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Foreign Key to Inherited table
Date
Msg-id 20031104132006.C67160@megazone.bigpanda.com
Whole thread Raw
In response to Foreign Key to Inherited table  (Greg Hulands <ghulands@bigpond.net.au>)
List pgsql-general
On Tue, 4 Nov 2003, Greg Hulands wrote:

> I have a table called Person that has a primary key personID. Another
> table called ProUser that inherits from Person. In another table called
> ProPriceSchedule I have a foreign key constraint to the ProUser table,
> like so: CONSTRAINT proUser FOREIGN KEY (personID) REFERENCES
> ProUser(personID).
>
> The problem I am having is this: ERROR: UNIQUE constraint matching
> given keys for referenced table "prouser" not found

That's because there isn't one. Primary keys, unique constraints and
foreign key constraints don't meaningfully inherit currently.  So, for now
ProUser has no unique constraint on the personID field unless you define
one in ProUser (and said constraint does not prevent a personID in Person
from being duplicated in ProUser).

pgsql-general by date:

Previous
From: Alexandr S
Date:
Subject: question
Next
From: Tom Lane
Date:
Subject: Re: Using SUBSELECT in CHECK expressions