This is probably mostly off topic, but I was using perl to do it since I couldn't figure out a way to do it natively in sql. What I have is basically a tree structure stored in a relational database system. The tree is stored by each node storing the id of it's parent, then I simply fetched the parent node, then fetched all of it's child nodes and recursed on that. However that required a lot of perl glue and I wondered if there was any more elegant method to retrieve the tree from the database?