Re: Self-referential records

Поиск
Список
Период
Сортировка
От Leif Biberg Kristensen
Тема Re: Self-referential records
Дата
Msg-id 201001241655.48404.leif@solumslekt.org
обсуждение исходный текст
Ответ на Re: Self-referential records  ("Wayne E. Pfeffer" <waynee.pfeffer@gmail.com>)
Список pgsql-general
On Sunday 24. January 2010 16.22.00 Wayne E. Pfeffer wrote:
> If you do not use null to represent a root node, when you go to unwind the
> data from the table to generate a hierarchy tree, you could end up with an
> infinite loop. The query will always be looking for the next parent in the
> hierarchy. Meaning, you will want to find the parent of a node using the
> given parent_id, the query will find the parent of 1 to be 1, then it will
> look again for the parent of 1 it will find 1, etc. etc. ad nauseum. I enjoy
> using recursion as much as the next guy, but this could cause some serious
> issues with the PostgreSQL query engine eating up system resources.

It doesn't really matter if the root node is NULL or 0 or whatever. You just
have to realize that the root node is a special case and program accordingly.
An adjacency tree is not a normalized structure, and will never be. It's the
programmer's responsibility to ensure that circular references can't occur.

regards,
--
Leif Biberg Kristensen
http://solumslekt.org/

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

Предыдущее
От: "Wayne E. Pfeffer"
Дата:
Сообщение: Re: Self-referential records
Следующее
От: "Davor J."
Дата:
Сообщение: Re: Referencing to system catalog problem