![]() | Ned Batchelder : Blog | Code | Text | Site Storing hierarchical data in a database » Home : Blog : November 2003 |
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.
tagged:
databases
/
via:
Keith Devens» 1 reaction | |
Comments
I was looking at this problem a few months ago and discovered this great article on an even better way to do it:
http://www.yafla.com/papers/sqlhierarchies/sqlhierarchies.htm
Add a comment: