473,770 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inheritance and foreign keys

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
6 2811
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
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 YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #3
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*******@postg resql.org

Nov 12 '05 #4
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*******@postg resql.org

Nov 12 '05 #5
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*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #6
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
42422
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed to be optional, it's very definition is it's a necessary link to the parent table and part of the definition. If it's optional it shouldn't be part of the definition of a table and should be in a linking table instead. Comments?
1
3006
by: Vinodh Kumar P | last post by:
I understand the number of foreign keys allowed is restricted by the DBMS I use. In a general relational schema design perspective how many foreign keys a table shall have? If I have large number of foreign keys what anamolies it will lead to? Is this crucial to identify all the foriegn key relationships for a table? Vinodh
0
1418
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A stored procedure updates a row in C, adds a row each in B & C. I get an integrity violation. All the foreign keys are deferrable, and the stored procedure is called from within a transaction with constraints deferred. (And the foreign keys do refer to...
4
2868
by: Bruno Baguette | last post by:
Hello, I've a strange problem with inheritance on PostgreSQL 7.4.1. It seems like tables don't inherits the primary key of the 'mother' table. Here's a little sample to show my problem : CREATE TABLE foo_a ( pk_idmyfoo INT2 PRIMARY KEY NOT NULL, myfoo_name VARCHAR(10)
5
2886
by: jao | last post by:
My company's product uses Postgres 7.4.3. Postgres is working well for us, and we've worked through many performance issues by tweaking the schema, indexes, and posgresql.conf settings. Inheritance would be useful for our application, but we did not use this feature initially. We're about to revise part of our application, and this would be a good time to introduce inheritance -- it's a good fit for our data model, and it would greatly...
2
2522
by: Ian Davies | last post by:
I have created a database with about 17 tables. I have been creating foreign keys some of which have worked but when creating others I get the message below ************************* 1005 (ER_CANT_CREATE_TABLE) Cannot create table. If the error message refers to errno 150, table creation failed because a foreign key constraint was not correctly formed.
9
3910
by: sonal | last post by:
Hi all, I hv started with python just recently... and have been assigned to make an utility which would be used for data validations... In short we take up various comma separated data files for eg: area.txt, school.txt, students.txt.... and so on (ok?!?) now, 1. area code used in the school.txt must be defined in the area.txt (Primary key in area => area_code defined in area.txt & Foreign key on school => area_code defined in...
1
3260
by: rbarber | last post by:
I have to synchronize 2 databases hourly but am having difficulty maintaining foreign key relations. These tables use auto-increment columns as primary keys, with child records in other tables related with foreign keys. I can't change the way the local software uses primary or foreign keys as it is hardcoded in the local app. (microsoft retail management system)..(however the web-remote app is easily customized). I am using CDB synchronizer to...
1
11011
by: apax999 | last post by:
Kinda new to SQL, using SQL Server 2005. I have some foreign keys in a couple of tables. I need to drop these tables, but can't since I'll get the error: Msg 3726, Level 16, State 1, Line 1 Could not drop object 'Client' because it is referenced by a FOREIGN KEY constraint.
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10259
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.