Thread: Inheritance and primary key

Inheritance and primary key

From
Guillaume Rousse
Date:
I use a super-class S (virtual, in fact) ans three inheritated classes S1, S2
and S3. i wish to have a primary key for all these classes, in order to use
queries as : SELECT * FROM S* WHERE s.id=x
I use a serial ID field for S as a primary key. Sequencing is OK, as any
insertion in any of the four classes increments the counter. But uniqueness
constraint is lost, as i can have duplicated values between differents classes.
And even in the same class for the inherited ones, as primary key propertie of
ID column is lost through inheritance. And i can't specify a unique constraint
on this column, as it is not present in the class definition.
How to solve this problem ?

--
Guillaume Rousse
*******************************************
Iremia -Universit� de la R�union
15 avenue Ren� Cassin, BP 7151
97715 Saint Denis, messagerie cedex 9
Tel:0262938287 Fax:0262938260 ICQ:10756815
Mail:Guillaume.Rousse@univ-reunion.fr

BRIDGEKEEPER: What... is the air-speed velocity of an unladen swallow?
ARTHUR: What do you mean? An African or European swallow?


Re: [GENERAL] Inheritance and primary key

From
Peter Eisentraut
Date:
This is a known bug (TODO item "Unique index on base column not honored on
inserts from inherited table"). Not sure though when or how this will be
fixed.

On 2000-01-10, Guillaume Rousse mentioned:

>
> I use a super-class S (virtual, in fact) ans three inheritated classes S1, S2
> and S3. i wish to have a primary key for all these classes, in order to use
> queries as : SELECT * FROM S* WHERE s.id=x
> I use a serial ID field for S as a primary key. Sequencing is OK, as any
> insertion in any of the four classes increments the counter. But uniqueness
> constraint is lost, as i can have duplicated values between differents classes.
> And even in the same class for the inherited ones, as primary key propertie of
> ID column is lost through inheritance. And i can't specify a unique constraint
> on this column, as it is not present in the class definition.
> How to solve this problem ?
>
> --
> Guillaume Rousse
> *******************************************
> Iremia -Université de la Réunion
> 15 avenue René Cassin, BP 7151
> 97715 Saint Denis, messagerie cedex 9
> Tel:0262938287 Fax:0262938260 ICQ:10756815
> Mail:Guillaume.Rousse@univ-reunion.fr
>
> BRIDGEKEEPER: What... is the air-speed velocity of an unladen swallow?
> ARTHUR: What do you mean? An African or European swallow?
>
>
> ************
>
>

--
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden