Re: PRIMARY KEY and INHERITANCE
Horst Herb <hherb@malleenet.net.au>
From: Horst Herb <hherb@malleenet.net.au>
To: Ferruccio Zamuner <nonsolosoft@diff.org>, pgsql-hackers@postgresql.org
Date: 2000-12-31T23:09:52Z
Lists: pgsql-hackers
On Monday 01 January 2001 01:42, Ferruccio Zamuner wrote: > Hi, > > some months ago I've asked for a suggestion for this bug: > > create table a ( > id serial primary key, > something text > ); > > create table b ( > morething text > ) inherits (a); > > create table c ( > trouble int references b; > ); > NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY > check(s) ERROR: PRIMARY KEY for referenced table "b" not found > > > How is possible to resolve this bug? > How is possible to talk about a ORDBMS with this kind of error? It is not a bug, I would call it a missing feature. I had the same problem, and somebody from this list helped me with a private email. I think this should be included in the FAQ and general documentation. What happens is that the attribute "id" is inherited, but the index on "id" is not. The workaround is: create unique index table_b_id on b(id); Then the index exists, and the foreign key can be referenced. Yes, I share your believe that the automatic generation of this index should be a minimum requirement for an _O_RDBMS, but who will have time to implement it properly? Regards, Horst