HELP! foreign eys & inheritance

Started by Horst Herbabout 25 years ago3 messages
#1Horst Herb
hherb@malleenet.net.au

The following example worked in previous versions (7.0.2 was the last I
tested), but not in 7.1 any more:

create table parent (
global_id serial
);

create table child (
anything text
) inherits (parent);

create table foreign (
fk_id int4 references parent(global_id) on update cascade on delete no action
) inherits (parent);

test.sql:83: ERROR: UNIQUE constraint matching given keys for referenced
table "child" not found
WHY ???

I would appreciate any help. Our database depends heavily on this.

Horst

#2Horst Herb
hherb@malleenet.net.au
In reply to: Horst Herb (#1)
Fwd: Re: HELP! foreign eys & inheritance

Ooops, sorry, error in this example:

The following example worked in previous versions (7.0.2 was the last I
tested), but not in 7.1 any more:

create table parent (
global_id serial
);

create table child (
anything text
) inherits (parent);

create table foreign (
fk_id int4 references child(global_id) on update cascade on delete no

action
^^^^^ child, of course, not parent!

) inherits (parent);

test.sql:83: ERROR: UNIQUE constraint matching given keys for referenced
table "child" not found
WHY ???

I would appreciate any help. Our database depends heavily on this.

Horst

-------------------------------------------------------

#3Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Horst Herb (#2)
Re: Fwd: Re: HELP! foreign eys & inheritance

You'll need to make a unique index/unique constraint on the fields
of child you wish to constrain. The unique constraint check wasn't
checked in 7.0, and also unique constraints are not inherited so
it has to be on the actual table you want to reference.

Stephan Szabo
sszabo@bigpanda.com

On Wed, 13 Dec 2000, Horst Herb wrote:

Show quoted text

Ooops, sorry, error in this example:

The following example worked in previous versions (7.0.2 was the last I
tested), but not in 7.1 any more:

create table parent (
global_id serial
);

create table child (
anything text
) inherits (parent);

create table foreign (
fk_id int4 references child(global_id) on update cascade on delete no

action
^^^^^ child, of course, not parent!

) inherits (parent);

test.sql:83: ERROR: UNIQUE constraint matching given keys for referenced
table "child" not found
WHY ???

I would appreciate any help. Our database depends heavily on this.

Horst

-------------------------------------------------------