Some time ago I was giving some thought to representing trees in a relational DB that could be queried in an efficient way and even made a prototype implementation. I may like to give it a try here, if I manage to find the code. Else I can sketch out the idea again.