[google-appengine] datastore design for hierarchical data.

96 views
Skip to first unread message

Gopal Patel

unread,
Apr 18, 2010, 8:29:54 AM4/18/10
to Google App Engine
hi , i am designing a simple project based to do list. the idea is to
define tasks under project ( no workflow - just "task is completed" or
not is required. ) in a hirarchial way. i.e. each task has multiple
task and that task may have other multiple task. a project can be said
to be completed if all task under that project are completed. , i
tought of using refrenceproeperty to create hirarchy , but could not
figure out easy way ( which do not take more than 30 seconds to find
all the children of a project and check weather it is completed or
not ) . to detect if project is complete or not. how to design
database for such job ? and also , if i need to copy the project in
order to define another project , how to copy hierarchical data ?

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

Gopal Patel

unread,
Apr 18, 2010, 8:33:29 AM4/18/10
to Google App Engine
one idea is to store both , reference value of project as well as
reference value of parent task in a child task. ( or referencelist
property ?? -- in that case , is it guranteed in appengine to
preserve list sequence ?? )

Jaroslav Záruba

unread,
Apr 18, 2010, 8:33:52 AM4/18/10
to google-a...@googlegroups.com
How about updating all ancestors on task status change? That way you wouldn't need to find all the children.

Tim Hoffman

unread,
Apr 18, 2010, 11:03:04 AM4/18/10
to Google App Engine
Here is the approach I would probably take unless you have many
hundreds of child tasks.

I would keep a list of keys of all children of each project/task.
(You can then do a db.get and get all immediate children with single
call)
and each child has a reference to it's parent. In addition in each
item keep a list of all parents keys back to the root. That way you
can search for all children
in part of the tree/subtree

(This approach is especially useful if you have multiple child types)
as back ref sets
are kind specific.

Keep a running count of complete children at each level, rather than
trying to calculate the current state in a single big function, (keep
these subsidiary values up to date through tasks)

T

Chris Tan

unread,
Apr 19, 2010, 5:18:21 AM4/19/10
to Google App Engine
I agree with this approach. It works well with tree data containing
fewer than 1000 nodes. It's also the amount of entities that
appengine can fetch in one query.

Here's some example code which I'm using for a forum, it may help you
get started:
http://gist.github.com/370861
It's running at: http://www.caterpi.com/forum

Nick Johnson (Google)

unread,
Apr 19, 2010, 7:00:03 AM4/19/10
to google-a...@googlegroups.com
Hi,


In general, please refrain from cross-posting here and on SO, unless you've posted to one and haven't received any satisfactory answers after a reasonable interval.

-Nick Johnson
--
Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047
Reply all
Reply to author
Forward
0 new messages