[nycphp-talk] Link to article about nested sets
Dan Cech
dcech at phpwerx.net
Mon Feb 2 16:14:40 EST 2009
Mitch Pirtle wrote:
> Apologies for the cross-post, I can't remember if this was a request
> from NYPHP or the NYCJUG. *blush*
>
> Somebody at the last meet was asking about nested sets, and I promised
> to get them the URL:
>
> http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
Ahh yes, good old nested sets. I still prefer the hybrid approach I
took with phpGACL (http://phpgacl.sf.net) and my old clew demo that
stores both both adjacency and nsm data.
For a very small storage overhead you get the benefits of both
approaches (try pulling immediate children from an nsm tree) and the
ability to rebuild the nsm data from scratch if it gets especially
messed up (not that there would ever be bugs...).
I've been meaning to sit down and try to figure out a variation using
intervals between the lft and rgt values so that inserts are cheaper,
just haven't had a project that needed it enough to motivate me yet!
If anyone wants to pick apart my old implementations feel free to check
out http://clew.phpwerx.net/, the source code is linked at the bottom.
Dan
More information about the talk
mailing list