Re: Storing a tree

Поиск
Список
Период
Сортировка
От Jochem van Dieten
Тема Re: Storing a tree
Дата
Msg-id 3BEA8DF4.5020802@oli.tudelft.nl
обсуждение исходный текст
Ответ на Storing a tree  (Antonio Fiol Bonnín <fiol@w3ping.com>)
Список pgsql-general
Antonio Fiol Bonnín wrote:

>
> I would like to store a tree in the database. A tree much like a
> directory tree, with un unknown depth.
>
> However, in my case, the order of the leafs (left to right) is
> important.
>
> I tried to implement the tree as a table:
>
> CREATE TABLE tree ( father_id int, son_id int );


There may be a better model for your data: the adjacency list model.
Take a look at http://www.intelligententerprise.com/001020/celko.shtml

If you want to implement it and you need/want to write stored procdures
and/or functions to do the most common list manipulation tasks we might
be able to work something out. I am a bit short of time at the moment,
but I believe it would be great if this stuff ended up in /contrib/ (or
is it there already?), and I am willing to invest time in that (but I am
leaving on holiday next week).

For more code, look at http://www.codebits.com/ntm/ (stored procedures
for using this model with MS SQL Server).

Jochem



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

Предыдущее
От: jeff@muttworks.com (Jeff Young)
Дата:
Сообщение: High Availability Cluster in Conjunction with PostGres
Следующее
От: "Richard Teviotdale"
Дата:
Сообщение: Re: OID's as Primary Keys