This is a very "RDBMS" way of approaching the problem, and I can see where
you are coming from. One of the challenges of App Engine is learning to take
advantage of the datastore features and redesigning your objects to match.
Without knowing exactly what you are planning to do, it can be difficult to
recommend a solution, as your solution may prove adequate.

An alternate solution could be to make use of List properties. Unlike SQL,
you can have a List property on an object and use equality filters to filter
for objects containing that property. For instance, if you have an Animal,
you could create a favoriteFoods property and add [ "spinach", "lettuce",
"bamboo" ] and be able to search using GQL (assuming you are using Python)
for this animal using the query "Select * from Animal where favoriteFoods ==
'bamboo'". It may make sense in your situation to use a List of child key
objects, then filter for that key. Here's some documentation:
http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ListProperty

There are also a set of pretty good articles that were published under the
"Articles" link for the "Mastering the Datastore" series you may want to
read: http://code.google.com/appengine/articles/

On Sat, Dec 19, 2009 at 3:07 PM, cppforlife <[email protected]> wrote:

> Hey all,
>
> I decided to play with app engine and got stuck on this problem.
> I have two entities List and ListItem. What I need to do is to
> associate many ListItems with a List however i cannot simply
> use db.ReferenceProperty in ListItem class because each ListItem can
> be part of multiple Lists. I figured that we can use
> db.ListProperty(db.key) in List class to keep multiple list items but
> is this
> efficient if each list would have about 100-200 items? However last
> method,
> cannot be used in my case becuase I need
> priority value for each ListItem and priority of ListItem might differ
> between different Lists for same ListItem so approach with
> ListProperty(db.key) doesnt work. I ended with this:
>
>
> class List(db.Model):
>    name = db.StringProperty()
>
> class ListToListItem(db.Model):
>    list = db.ReferenceProperty(List)
>    item = db.ReferenceProperty(ListItem)
>    priority = db.Int...
>
> class ListItem(db.Model):
>    name = db.StringProperty()
>
>
> Am I doing this right or there is a better/efficient way?
>
> Thank you in advance,
> Dmitriy
>
> --
>
> 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]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine

--

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