Storing hierarchical data in a database

Tuesday 18 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.

Comments

[gravatar]
CharlesC 5:50 PM on 21 Nov 2003

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:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.