Old Solutions For New Problems
Back in 2001 I was working on a project that required hierarchical (tree) data to be stored in a SQL Server 2000 database. We had to query all children of a certain node, and the entire sub-tree of a certain node, etc. Because SQL Server didn’t support hierarchical queries at that time, I read some articles by Joe Celko and used his ideas to devise a storage algorithm using a “left-right” value for each node. I wrote a detailed article about the approach and it was the front cover article of the September 2001 issue of SQL Server Professional magazine.
It’s no longer available online via the magazine, but you can read the article here:
http://www.nolanzak.com/whitepapers/HierarchicalData/nzHier.htm
SQL Server 2008 and newer all support hierarchical data, so you don’t really need to be that complicated anymore. But what about if you want to write software that can use any database engine? Back then the web was in an early stage, and it was not common to create applications that could use any database system. Most apps were tied to a particular database vendor. Fast forward to today, and “retail” web-based apps are increasingly available to customers. You buy it, download it, and install it locally using whatever database you have available.
When I was working on the original implementation of my hierarchical algorithm, I didn’t realize that the solution was ANSI-SQL compliant and would work on any relational database engine that supported ANSI-SQL. If you wanted to write an application that managed hierarchical data and used any database engine, you’d be safe with my algorithm.
Well I just came across an article from Fog Creek. Fog Creek is Joel (Joel on Software)Spolsky’s company, the makers of FogBugz. In my opinion, Fogbugz is one of the best bug tracking applications available, and Joel is a well-respected member of the software community. Turns out that they are using something very similar to my algorithm in order to manage their new feature of using hierarchical data in FogBugz:
http://www.fogcreek.com/FogBugz/blog/post/Subcases-and-Hierarchy.aspx
It goes to show that old ideas and techniques can be valuable solutions for different issues, long after their original intended use. Keep all your work and everything you’ve learned in your archive and re-visit it occasionally, you might find something old that helps you with a current problem.