Re: Best way to store a threaded message list/tree in SQL

From: Johan Nel <johan555(dot)nel555(at)xsinet555(dot)co(dot)za>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Best way to store a threaded message list/tree in SQL
Date: 2009-03-27 03:31:09
Message-ID: gqhhdu$vav$1@news.motzarella.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mike,
connectby() is your friend here. Do a search on tablefunc in the help file.
> CREATE Table wallposts
> (
> id uuid NOT NULL,
> posted timestamp NOT NULL,
> userid uuid NOT NULL,
> posterid uuid NOT NULL,
> parentid uuid NOT NULL,
> comment text NOT NULL
> )
SELECT * FROM connectby('wallposts', 'id', 'parentid', '<entrypoint>',
0, '~')
AS t(keyid text, parent_keyid text, level int, branch text);

HTH,

Johan Nel
Durban, South Africa.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2009-03-27 06:24:58 Re: Is there a meaningful benchmark?
Previous Message Guy Rouillier 2009-03-27 01:54:27 Re: Enumerating a row set