Re: Self referencing composite datatype
От | Sergey Konoplev |
---|---|
Тема | Re: Self referencing composite datatype |
Дата | |
Msg-id | CAL_0b1vtM06eab5d5WecKmRR01h6SueWBJwj3wpVpB8gDMSZ_w@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Self referencing composite datatype (Alban Hertroys <haramrae@gmail.com>) |
Список | pgsql-general |
On Wed, Aug 7, 2013 at 11:38 PM, Alban Hertroys <haramrae@gmail.com> wrote: > On Aug 8, 2013, at 4:11, Sergey Konoplev <gray.ru@gmail.com> wrote: >> create table node as ( >> id integer primary key, >> r integer, s integer, >> children integer[] >> ); >> >> and check integrity by triggers. > > > Or, instead of attempting to reference all child nodes from the parent, reference the parent node from each child node. > That's been supported in PG versions like forever and can be queried fairly efficiently using recursive CTE's since PG9. That particular moment I thought it was about graphs. Later OP mentioned tree, so yes, it is better to use parent reference here. -- Kind regards, Sergey Konoplev PostgreSQL Consultant and DBA http://www.linkedin.com/in/grayhemp +1 (415) 867-9984, +7 (901) 903-0499, +7 (988) 888-1979 gray.ru@gmail.com
В списке pgsql-general по дате отправления: