Re: Inheritance and foreign keys

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: Inheritance and foreign keys
Дата
Msg-id 3FD5C766.50609@Yahoo.com
обсуждение исходный текст
Ответ на Re: Inheritance and foreign keys  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Ответы Re: Inheritance and foreign keys
Список pgsql-general
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.                                  #
#================================================== JanWieck@Yahoo.com #


В списке pgsql-general по дате отправления:

Предыдущее
От: "John Sidney-Woollett"
Дата:
Сообщение: Re: Select for update Question
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Shell access & send email from PLPGSQL?