By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,541 Members | 1,525 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,541 IT Pros & Developers. It's quick & easy.

Inheritance and foreign keys

P: n/a
Hi all,

I read on the manual page for Inheritance that:

"A limitation of the inheritance feature is that indexes (including
unique constraints) and foreign key constraints only apply to single
tables, not to their inheritance children. Thus, in the above example,
specifying that another table's column REFERENCES cities(name) would
allow the other table to contain city names but not capital names. This
deficiency will probably be fixed in some future release."

I have a few projects that could benefit from inherited table structure,
and it's a very cool idea, but this inability of indexes to include
derived tables is a real functionality-killer. It's not "Object
Relational" if the objects can't be related to anything!

If someone could give me an idea of how far away this fix is, I'd be
grateful.

Cheers

BJ
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Brendan Jurd wrote:
I have a few projects that could benefit from inherited table
structure, and it's a very cool idea, but this inability of indexes
to include derived tables is a real functionality-killer. It's not
"Object Relational" if the objects can't be related to anything!
Hehe, but the "relational" means that the data is stored in relations,
not that the data has to be related to other data.
If someone could give me an idea of how far away this fix is, I'd be
grateful.


No one has really expressed intentions to fix this, so I wouldn't hold
my breath.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #2

P: n/a
On Tue, 9 Dec 2003, Brendan Jurd wrote:
Hi all,

I read on the manual page for Inheritance that:

"A limitation of the inheritance feature is that indexes (including
unique constraints) and foreign key constraints only apply to single
tables, not to their inheritance children. Thus, in the above example,
specifying that another table's column REFERENCES cities(name) would
allow the other table to contain city names but not capital names. This
deficiency will probably be fixed in some future release."

I have a few projects that could benefit from inherited table structure,
and it's a very cool idea, but this inability of indexes to include
derived tables is a real functionality-killer. It's not "Object
Relational" if the objects can't be related to anything!

If someone could give me an idea of how far away this fix is, I'd be
grateful.


I'd say at least 1, probably more versions out. Unique constraints across
an inheritance tree are pretty much a requirement for inherited foreign
keys and I'm not planning to even start thinking about the foreign key
side until after unique's done.

As a note, there are workarounds for foreign keys that have been mentioned
in the past. I'm not really sure anyone's post a real good workaround for
unique though.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #3

P: n/a
On Mon, 8 Dec 2003, Stephan Szabo wrote:
On Tue, 9 Dec 2003, Brendan Jurd wrote:
Hi all,

I read on the manual page for Inheritance that:

"A limitation of the inheritance feature is that indexes (including
unique constraints) and foreign key constraints only apply to single
tables, not to their inheritance children. Thus, in the above example,
specifying that another table's column REFERENCES cities(name) would
allow the other table to contain city names but not capital names. This
deficiency will probably be fixed in some future release."

I have a few projects that could benefit from inherited table structure,
and it's a very cool idea, but this inability of indexes to include
derived tables is a real functionality-killer. It's not "Object
Relational" if the objects can't be related to anything!

If someone could give me an idea of how far away this fix is, I'd be
grateful.


I'd say at least 1, probably more versions out. Unique constraints across


Errm, that was supposed to say "at least 2," given the absense of a good
plan.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #4

P: n/a
Stephan Szabo wrote:
On Tue, 9 Dec 2003, Brendan Jurd wrote:
Hi all,

I read on the manual page for Inheritance that:

"A limitation of the inheritance feature is that indexes (including
unique constraints) and foreign key constraints only apply to single
tables, not to their inheritance children. Thus, in the above example,
specifying that another table's column REFERENCES cities(name) would
allow the other table to contain city names but not capital names. This
deficiency will probably be fixed in some future release."

I have a few projects that could benefit from inherited table structure,
and it's a very cool idea, but this inability of indexes to include
derived tables is a real functionality-killer. It's not "Object
Relational" if the objects can't be related to anything!

If someone could give me an idea of how far away this fix is, I'd be
grateful.


I'd say at least 1, probably more versions out. Unique constraints across
an inheritance tree are pretty much a requirement for inherited foreign
keys and I'm not planning to even start thinking about the foreign key
side until after unique's done.

As a note, there are workarounds for foreign keys that have been mentioned
in the past. I'm not really sure anyone's post a real good workaround for
unique though.


Wouldn't a central table just holding the unique key values and
maintained by rules/triggers from all the tables in the inheritance tree
do the trick?

That central table would be the referenced one too then, because it
contains the union of all keys.

It would not inherit automagically, but if set up manually that way it
would act correct.
Jan

--
#================================================= =====================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================= = Ja******@Yahoo.com #
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #5

P: n/a
On Tue, 9 Dec 2003, Jan Wieck wrote:
Stephan Szabo wrote:
On Tue, 9 Dec 2003, Brendan Jurd wrote:

As a note, there are workarounds for foreign keys that have been mentioned
in the past. I'm not really sure anyone's post a real good workaround for
unique though.


Wouldn't a central table just holding the unique key values and
maintained by rules/triggers from all the tables in the inheritance tree
do the trick?

That central table would be the referenced one too then, because it
contains the union of all keys.


That's the general thing for the fks and I guess the insert into the
central table should have the correct behavior in concurrent calls as
well.
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #6

P: n/a
Stephan Szabo wrote:
On Tue, 9 Dec 2003, Jan Wieck wrote:
Stephan Szabo wrote:
> On Tue, 9 Dec 2003, Brendan Jurd wrote:
>
> As a note, there are workarounds for foreign keys that have been mentioned
> in the past. I'm not really sure anyone's post a real good workaround for
> unique though.


Wouldn't a central table just holding the unique key values and
maintained by rules/triggers from all the tables in the inheritance tree
do the trick?

That central table would be the referenced one too then, because it
contains the union of all keys.


That's the general thing for the fks and I guess the insert into the
central table should have the correct behavior in concurrent calls as
well.


I'm not 100% sure though. Is there any possibility that an entry in a
table hides an entry in an inherited one?
Jan

--
#================================================= =====================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================= = Ja******@Yahoo.com #
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.