inherited sequences and primary keys

Started by Brett McCormickalmost 28 years ago4 messages
#1Brett McCormick
brett@work.chicken.org

I've got a table that has a primary key with a default of
nextval('seq'). I've got another table which inherits this one, but
it fails to inherit the unique btree index. It does inherit the
default value. So, I'm assuming that if I create a unique index for
that field on the child table, it won't keep you from inserting values
that exist in that field in the parent table (and since they both
share the same sequence, that's what I want).

So primary keys do not work in this situation. Are there plans to
enhance the inheritance? I have no idea how it works, is it
intelligent? Seems more klunky than not, but I haven't really looked
at the code. Should I stop using inheritance altogether, considering
its drawbacks (no idea what child class it is in when selecting from
parent and all children, no shared indices/pkeys) when I don't select
from them all at once?

#2Maurice Gittens
mgittens@gits.nl
In reply to: Brett McCormick (#1)
Re: [HACKERS] inherited sequences and primary keys

I've got a table that has a primary key with a default of
nextval('seq'). I've got another table which inherits this one, but
it fails to inherit the unique btree index. It does inherit the
default value. So, I'm assuming that if I create a unique index for
that field on the child table, it won't keep you from inserting values
that exist in that field in the parent table (and since they both
share the same sequence, that's what I want).

This is the way it should work IMO.

So primary keys do not work in this situation. Are there plans to
enhance the inheritance? I have no idea how it works, is it
intelligent? Seems more klunky than not, but I haven't really looked
at the code. Should I stop using inheritance altogether, considering
its drawbacks (no idea what child class it is in when selecting from
parent and all children, no shared indices/pkeys) when I don't select
from them all at once?

IMO the current semantics for inheritance in Postgresql are broken.
I've been wanting to do something about it but I got distracted and started
to debug some other problems in the system.

I hope to get back to this some time.

I personally feel that we have to make some choices:

Is postgresql going to be an Object Relational dbms or is it going to
be yet another relation dbms?

When the developers make an explicite choice on this point it will be a
Good Thing (tm).

With regards from Maurice.

#3Noname
dg@illustra.com
In reply to: Maurice Gittens (#2)
Re: [HACKERS] inherited sequences and primary keys

Maurice:

IMO the current semantics for inheritance in Postgresql are broken.

It seems that way.

I've been wanting to do something about it but I got distracted and started
to debug some other problems in the system.

I hope to get back to this some time.

I personally feel that we have to make some choices:

Is postgresql going to be an Object Relational dbms or is it going to
be yet another relation dbms?

When the developers make an explicite choice on this point it will be a
Good Thing (tm).

Agreed. There are lots of pretty decent relation dbms's out there. There are
very few Object Relational dbms's. I happen to think ORDBMS is a really cool
idea and have seen some great applications done with it that a straight
up RDBMS just couldn't do. So my vote is for ORDBMS.

That said, postgresql needs to become a much better RDBMS that it currently
is.

-dg

David Gould dg@illustra.com 510.628.3783 or 510.305.9468
Informix Software (No, really) 300 Lakeside Drive Oakland, CA 94612
- Linux. Not because it is free. Because it is better.

#4Vadim B. Mikheev
vadim@sable.krasnoyarsk.su
In reply to: Noname (#3)
Re: [QUESTIONS] Re: [HACKERS] inherited sequences and primary keys

David Gould wrote:

Agreed. There are lots of pretty decent relation dbms's out there. There are
very few Object Relational dbms's. I happen to think ORDBMS is a really cool
idea and have seen some great applications done with it that a straight
up RDBMS just couldn't do. So my vote is for ORDBMS.

That said, postgresql needs to become a much better RDBMS that it currently
is.

Agreed.
Unfortunately, there are many problems in all areas of postgres.
And time is limited :(

Vadim