Joe Celko's Trees and hierarchies in SQL for smarties. (©2004)