From: Josh Berkus <josh@agliodbs.com>
To: gzscott2001@yahoo.ca
To: pgsql-sql@postgresql.org
Subject: Re: Get A Tree from a table
Date: Mon, 07 Oct 2002 09:40:37 -0700
Message-ID: <web-1773971@davinci.ethosmedia.com> (raw)
In-Reply-To: <341834e1.0210052137.7cbd6342@posting.google.com>
Scott,
> NODES__________________________________
> ParentID Varchar(20)
> ParentType varchar(20)
> ChildID varchar(20)
> ChildType varchar(20)
This looks difficult... mainly becuase, in your shema, a "parent" node
can be its own child or grandchild, resulting in an endless loop.
If that was not your intention, you may wish to think of using a
different structure.
There are two main ways for you to approach this problem in 7.2.x:
1) Buy Joe Celko's "SQL for Smarties" and read up on pure-SQL tree
implementations, which he covers in far more depth than I want to here;
2) Explore the tree module in /contrib in your Postgresql source.
I understand from Joe Conway that in 7.3, you will have another choice,
as Postgres will offer support for Oracle's tree-like "IS CONNECTED BY"
expression.
Good luck!
-Josh Berkus
P.S. also, there's some articles on tree structures up at techdocs:
http://techdocs.postgresql.org/
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, gzscott2001@yahoo.ca
Subject: Re: Get A Tree from a table
In-Reply-To: <web-1773971@davinci.ethosmedia.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