Re: Inheritance on foreign key

From: Erik Jones <ejones(at)engineyard(dot)com>
To: Takeichi Kanzaki Cabrera <tkanzakic(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Inheritance on foreign key
Date: 2009-10-12 18:21:36
Message-ID: 0CC9C7C6-F44D-4530-B185-C8516027F451@engineyard.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Oct 9, 2009, at 9:57 AM, Takeichi Kanzaki Cabrera wrote:

> Hi everybody, I need your help. I have a hierarchy of tables, and
> other table that has a foreign key with the top table of the
> hierarchy, can I insert a value into the "other" table where the value
> it reference is not on the parent table? (it's in one of its child)

No, foreign key checks do not (yet) follow inheritance hierarchies.
Here's the specific clause in the manual (http://www.postgresql.org/docs/8.4/interactive/ddl-inherit.html
) that covers this:

"All check constraints and not-null constraints on a parent table are
automatically inherited by its children. Other types of constraints
(unique, primary key, and foreign key constraints) are not inherited."

Erik Jones, Database Administrator
Engine Yard
Support, Scalability, Reliability
866.518.9273 x 260
Location: US/Pacific
IRC: mage2k

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dave Huber 2009-10-12 19:12:35 creating a function with another function
Previous Message Joshua D. Drake 2009-10-12 18:10:56 PostgreSQL Conference West, registration closing