pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Gregory Brauer <greg@wildbrain.com>
To: pgsql-sql@postgresql.org
Subject: Re: Trees in SQL
Date: Mon, 27 May 2002 13:06:53 -0700
Message-ID: <200205271306.53646.josh@agliodbs.com> (raw)
In-Reply-To: <3CEE818B.9020702@wildbrain.com>
References: <3CEE818B.9020702@wildbrain.com>

Greg,

> What sort of strategies are best for storing tree structures in a
> relational database, and how would one structure SQL queries to find,
> say, "all of the children anywhere under this node", or to represent
> the condition "if this node is a child at any depth under this other
> node"?  Are there good strategies for preventing cycles?

Joe Celko covers this extensively in his book "SQL for Smarties."  You should 
definitely buy it and read the two chapters on tree structures before going 
any further.

I will be writing an article for Techdocs within the month on implementing 
Celko's "Linear Nested Sets Model" of trees in PostgreSQL.  If you can't 
wait, buy the book, e-mail me, and I'll send you my notes.

-- 
-Josh Berkus






view thread (12+ messages)  latest in thread

Message-ID: <200205271306.53646.josh@agliodbs.com>
Permalink:  ../200205271306.53646.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200205271306.53646.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, greg@wildbrain.com
  Subject: Re: Trees in SQL
  In-Reply-To: <200205271306.53646.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox