spacedman wrote:
> If you can rework your database slightly you can use Modified Preorder
> Tree Traversal, which is a really slick way of doing trees in
> relational databases. You can get everything you need to know to
> present a tree diagram with ONE database call. If you store parent-id
> then you can end up hitting the database many many more times as you
> climb up and down the tree.
>
> See
> http://code.djangoproject.com/wiki/ModifiedPreorderTreeTraversal
>
> And
> http://www.sitepoint.com/print/hierarchical-data-database
>
> It takes a bit of thinking about, but once it 'clicks' you'll see how
> neat it is.
>
> Barry

When I've dealt with large trees in a web application, a big part of
the problem has been in sending the structure of the entire tree back
to the client. In that situation we retrieved the top-level nodes only,
and expanded nodes for a specific parent only when requested. This was
trivial with the naive parent_id approach. I can't see any way of doing
this with MPTT - Is there any way in this storage method to get the
children of a node without also getting all descendants?

I guess you could store both the l/r values and parent_id - but that's
less than ideal.

Thanks - I hadn't seen the MPTT method before. It looks to be useful,
in the right circumstances.

Cheers,
xtian


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to