what about uniqueness of inherited primary keys - Mailing list pgsql-general

From Andreas
Subject what about uniqueness of inherited primary keys
Date
Msg-id 3FEF3A57.4080407@gmx.net
Whole thread Raw
Responses Re: what about uniqueness of inherited primary keys  (Scott Ribe <scott_ribe@killerbytes.com>)
Re: what about uniqueness of inherited primary keys  (Oliver Elphick <olly@lfix.co.uk>)
Re: what about uniqueness of inherited primary keys  (Seastian Böck <sebastianboeck@freenet.de>)
List pgsql-general
Hello list,

what about uniqueness of inherited primary keys ?

eg you have :

create table objects (
  id int4,
  date_created   timestamp(0),
  primary key (id)
);

create table persons (
  firstname  varchar(100),
  lastname  varchar(100)
) inherits (objects);

now ...

insert into objects (id) values (1);
A repetition of this line would cause an unique-constraint error of
objects_pkey.

insert into persons (id, firstname, lastname) values (1, 'Super', 'Man');
insert into persons (id, firstname, lastname) values (1, 'Bat', 'Man');
works though it violates the inherited constraint.

A  select * from objects;  shows id=1 three times.

delete * from objects;   empties both tables.

after   ALTER TABLE public.persons  ADD CONSTRAINT persons_pkey PRIMARY
KEY(id);
I can still insert at least one record with id=1 in each table.

select count(*) from objects where id=1;
results  2

Shouldn't we expect to have unique entries in a primary key collumn ?



pgsql-general by date:

Previous
From: Tony
Date:
Subject: Re: Is my MySQL Gaining ?
Next
From: Scott Ribe
Date:
Subject: Re: what about uniqueness of inherited primary keys