Table Inheritance and Foreign Keys

Поиск
Список
Период
Сортировка
От Riaan Stander
Тема Table Inheritance and Foreign Keys
Дата
Msg-id 003501d4c70d$b7a8c3e0$26fa4ba0$@exa.co.za
обсуждение исходный текст
Ответы Re: Table Inheritance and Foreign Keys  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general

Good day

 

I’ve got a scenario where I’m building a table structure that allows for building a tree. In order to properly separate the different column requirements I’ve looked at using table inheritance.

Example structure:

 

CREATE TABLE base_table

(

    id    bigint primary key,

    parent_id    bigint,

    some_common_columns ….

)

 

CREATE TABLE folder

(

    id    bigint primary key,

    some_folder_specific_columns …

) INHERITS(base_table)

 

CREATE TABLE node_type_x

(

    id    bigint primary key,

    some_node_x_specific_columns….

) INHERITS (base_table)

 

Now obviously when inserting folders and node type x records they would go to their respective tables, but with the table inheritance I can query base_table to get them all.

The rules state that folders can only be inserted under folders, but node type x can go under folders or other node type x’s.

 

Now if I want to add a foreign key to the base table from node type x I get an error due to Postgres not supported this scenario. The documentation talks about this, but also state as follows

These deficiencies will probably be fixed in some future release, but in the meantime considerable care is needed in deciding whether inheritance is useful for your application”

 

My question is if anybody knows more as to if and when this actually will be allowed/solved.

 

Regards

Riaan

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

Предыдущее
От: legrand legrand
Дата:
Сообщение: pg_stat_statements doesn't track commit from pl/pgsql blocks
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Table Inheritance and Foreign Keys