Login

Snippets by lars.yencken

Snippet List

Nested set abstraction for hierarchical data

The nested set abstraction is a very nice way to store hierarchical data, for example places, in a database. It provides an easy way to say that Melbourne is within Victoria, which is within Australia, etc.</p> The calls to addChild() are expensive, so this model is slow to build, and bad if you do frequent updates. If you're building a read-only model though, it's much faster than ForeignKey('self') for determining ancestor/descendent relationships.

  • tree
  • hierarchy
  • nested-set
Read More

lars.yencken has posted 1 snippet.