Keeping tree-structured data in a relational database is always a challenge. Storing Hierarchical Data In A Database demonstrates a nifty technique that is heavily tipped toward fast queries. It stores two numbers that link all the nodes together in a depth-first traversal. This makes all sorts of queries possible and efficient, but updating rows is a real pain. If you have data that is read far more often than written, it could be a good choice.