RailsCasts Pro episodes are now free!

Learn more or hide this

Len Jaffe's Profile

GitHub User: vampirechicken

Site: www.theycomewithcheese.com

Comments by Len Jaffe


Ancestry uses the Materialized Path (MP) technique for encoding nested trees. It differs from Nested Set (NS) encoding in that with nested sets, each insert/update/delete updates close to half of the records in the tree. With MP, only the manipulated node and its descendants are modified.

This page [https://communities.bmc.com/communities/docs/DOC-9902] is a pretty good analysis of the three well-known nested tree encodings. Also, the book SQL for Smarties by Joe Celko treats this topic very nicely.

Thanks for this Railscast, I'll be needing nested tress very soon, and was not relishing writing my own implementation of MP.