Hi Peter,

On Sun, Jul 12, 2009 at 8:31 PM, Peter Cicman<[email protected]> wrote:
>
> I had spend some time today with building tree structure using
> datastore. I need a real tree, for real world, so there must be a
> possibility to move node with all descendants. There must also be a
> quick way to find all ancestors, children and descendants.

I'm not aware of any tree structure that fits both those requirements
- in fact, I'm fairly sure it's not possible.

There are two basic approaches to representing trees: Ones that
encompass the node's position in the entire tree, such as materialized
path and nested set notation, and ones that only encompass the node's
relationship to neighbouring nodes, such as adjacency lists. The
former permit easily querying all descendants, while the latter make
it easy to move entire branches. I don't think it's possible to have
both at once.

If moving a branch is less common than querying, and your trees are
relatively shallow (Say, less than 100 levels deep), I would recommend
using the materialized path approach: Have a ListProperty that lists
all the ancestors of the node.

-Nick Johnson

>
> So, datastore keys can not be used for tree like this - because key
> can not change, and i would like to prevent node copying/deletion,
> because this must be always done on node and all its descendants which
> may end up with tons of sql queries.
>
> Design i made should fit for me, but maybe there is some common
> solution for this problem... Anybody knows about some optimal
> solution? (i can not use serialization)
>
> Thanks a lot!
> >
>



-- 
Nick Johnson, App Engine Developer Programs Engineer
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration
Number: 368047

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to