pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Question on Inheritance and Primary Keys.
4+ messages / 2 participants
[nested] [flat]

* Question on Inheritance and Primary Keys.
@ 1999-10-11 19:26  Dutt Kalapatapu <dutt@eudoramail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Dutt Kalapatapu @ 1999-10-11 19:26 UTC (permalink / raw)
  To: pgsql-interfaces; +Cc: pgsql-sql@postgreSQL.org; dutt@pacbell.net


I have two Tables:

TableA(
parameterone int,
parametertwo int,
PRIMARYKEY(parameterone),
UNIQUE(parameterone)
);

TableB(
parameterthree int
)INHERITS(TableA);


I expect from this that when we insert some thing in TableB then
parameterone should be unique, but the database is not enforcing the rule
and it takes duplicate values.  But when I insert two duplicate keys in
TableA then it complains.  This means that Inheritance removes the
primarykey etc from the inherited table??? I couldn't think why this object
oriented behaviour doesn't work here.


Can some one explain this behaviour.

Thanks
Dutt

--Dutt Kalapatapu
    ________________________
   |ipVerse Inc.,           |
   |1901 Landings Drive     |
   |Mountain View, CA-94043 |
   |Telefono: 650 919 0647  |
   |________________________|



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] Question on Inheritance and Primary Keys.
@ 1999-10-12 01:21  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Dutt Kalapatapu <dutt@eudoramail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 1999-10-12 01:21 UTC (permalink / raw)
  To: Dutt Kalapatapu <dutt@eudoramail.com>; +Cc: pgsql-interfaces; pgsql-sql@postgreSQL.org; dutt@pacbell.net

Dutt Kalapatapu <dutt@eudoramail.com> writes:
> I expect from this that when we insert some thing in TableB then
> parameterone should be unique, but the database is not enforcing the rule
> and it takes duplicate values.

Constraints and indexes aren't inherited; you have to redeclare them for
each derived table.  I agree this is a bug, or at least lack of a
feature that ought to be there.  It's on the TODO list, in fact:

* Unique index on base column not honored on inserts from inherited table
  INSERT INTO inherit_table (unique_index_col) VALUES (dup) should fail
  [inherit] 

I don't know when it might get fixed.  None of the currently active
developers seem to be very interested in inheritance issues, so it
could be a while before anyone decides to look at this problem.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] Question on Inheritance and Primary Keys.
@ 1999-10-12 01:30  Dutt Kalapatapu <dutt@eudoramail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Dutt Kalapatapu @ 1999-10-12 01:30 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-interfaces; pgsql-sql@postgreSQL.org; dutt@pacbell.net




If I redeclare the Values again, will it overwrite the inherited values?

Thanks for the clarification.
-Dutt

At 09:21 PM 10/11/99 -0400, Tom Lane wrote:
>Dutt Kalapatapu <dutt@eudoramail.com> writes:
>> I expect from this that when we insert some thing in TableB then
>> parameterone should be unique, but the database is not enforcing the rule
>> and it takes duplicate values.
>
>Constraints and indexes aren't inherited; you have to redeclare them for
>each derived table.  I agree this is a bug, or at least lack of a
>feature that ought to be there.  It's on the TODO list, in fact:
>
>* Unique index on base column not honored on inserts from inherited table
>  INSERT INTO inherit_table (unique_index_col) VALUES (dup) should fail
>  [inherit] 
>
>I don't know when it might get fixed.  None of the currently active
>developers seem to be very interested in inheritance issues, so it
>could be a while before anyone decides to look at this problem.
>
>			regards, tom lane
>
--Dutt Kalapatapu
    ________________________
   |ipVerse Inc.,           |
   |1901 Landings Drive     |
   |Mountain View, CA-94043 |
   |Telefono: 650 919 0647  |
   |________________________|



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] Question on Inheritance and Primary Keys.
@ 1999-10-12 01:36  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Dutt Kalapatapu <dutt@eudoramail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 1999-10-12 01:36 UTC (permalink / raw)
  To: Dutt Kalapatapu <dutt@eudoramail.com>; +Cc: pgsql-interfaces; pgsql-sql@postgreSQL.org; dutt@pacbell.net

What you declare for the derived table doesn't affect the parent,
if that's what you meant.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~1999-10-12 01:36 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-10-11 19:26 Question on Inheritance and Primary Keys. Dutt Kalapatapu <dutt@eudoramail.com>
1999-10-12 01:21 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-10-12 01:30 Re: [SQL] Question on Inheritance and Primary Keys. Dutt Kalapatapu <dutt@eudoramail.com>
1999-10-12 01:36 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox