Re: inheritance and FK

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Oleg Lebedev <oleg(dot)lebedev(at)waterford(dot)org>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: inheritance and FK
Date: 2003-03-03 20:21:38
Message-ID: 20030303122023.J40687-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 3 Mar 2003, Oleg Lebedev wrote:

> I am trying to create two tables: parent and child. Child inherits from
> the parent and has a foregn key (FK) referencing parent's primary key
> (PK). Suppose parent table has one row with PK = 1 and I have one row in
> the child table with FK=1 and PK=2. Now, I want to insert another row in
> the child table with FK = 2, however it won't let me do this, since
> parent table does not have a record with PK = 2.
> I was expecting that children tables will also be searched when
> verifying a foreign key constraint referencing the parent table.
> Is there a way to force this kind of "hierarchical" foreign key
> constraint check?

Not currently. Currently the check is applied only to the named table.
In general, inheritance needs alot of work, and we need a comprehensive
plan for all the problems (for example, primary keys also don't inherit).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dennis Gearon 2003-03-03 20:31:36 Re: almost there on a design
Previous Message Oleg Lebedev 2003-03-03 20:19:14 inheritance and FK