• Turn the adjacency hierarchy into a standard many-to-many (joining the primary table back to itself), with a date-effective range in the join table.

    When you build the CTE, you just have to include both tables, and then it works just like any other adjacency hierarchy.

    The biggest issue with this is that it becomes possible to have the same node at multiple levels of the hierarchy, which isn't possible in a single-table version. You thus have to use moderately complex code to make sure that inserts and updates don't allow that, or you end up with infinite recursion problems.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon