PostgreSQL and inherits

Поиск
Список
Период
Сортировка
От Jan Johansson
Тема PostgreSQL and inherits
Дата
Msg-id CAGbXvMbMK8PZAQWn1tK3vZnaCMxcSnwyfR4_v8r-rKTXqd9SqA@mail.gmail.com
обсуждение исходный текст
Список pgsql-hackers
Hi,

I want to discuss about inherits in PostgreSQL.
Everything I write here is my own opinion, but I hope for a good dialog.

I think that inherits is a feature to good to be plain legacy, but it is unfortunately riddled with some inconsistencies. The inheritance keyword link tables together in a "is-a" chain, from child up to parent. The children has the same fields as the parent, plus their own (if they declare).

In one way there is an illusion of object orientation, where the children share data with the parent (comes from when you select from a parent in the inheritance and you see the data), but in another way if you use the condition "only" (in select) or discover that field behavior (primary key, foreign key, etc) is not inherited, then inheritance is of the behavior of interface.

It's like the implementation sits on the fence, and does not know if inherits is object oriented, or if it is interface oriented.

This inconsistency makes the feature not as smooth as it could be.

A suggestion would be to walk down the path for the object oriented approach, meaning that fields shared with the parent, also share behavior (primary key, foreign key, etc). This suggestion might break compatibility with some implementations (using inheritance and where coding has been done to account for the object-interface-oriented approach).

Another suggestion would be to walk down the path for the interface oriented approach, meaning that nothing is shared between the child and parent, except for the field name and types. This may also break compatibility.

The third suggestion would be to let inheritance be as it is, but to introduce "extends" keyword to make a more clean object-oriented approach to the "is-a" chain. Then nothing is broken, but it adds complexity to the schema.

I'd be happy to know your reflections about the subject.

Kind regards


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

Предыдущее
От: Amit Langote
Дата:
Сообщение: pg_xlogfile_name_offset() et al and recovery
Следующее
От: Amit Langote
Дата:
Сообщение: Re: Declarative partitioning