I've been trying to figure this one out for a few hours now:

I have an ever growing table of questions, and an ever growing table of 
users.  For a given user, I would like to query for 5 random questions that 
they have not already answered.  What kind of model schema would allow this?

I've seen how to query for N (semi)random 
entities<http://stackoverflow.com/questions/3002999/fetching-a-random-record-from-the-google-app-engine-datastore>
 (which 
uses a > query filter), and I've seen the presentation 
<http://www.google.com/events/io/2009/sessions/BuildingScalableComplexApps.html>on
 
how to do microblogging style schemas (which uses = on lists as a query 
filter), which together might allow me to query for '5 random questions the 
user *has* already answered'.  To do the opposite though would require > 
and != on different properties which isn't allowed.

The best I can come up with so far is to keep a list of the answered 
questions on the user entity, then query for batches of random questions 
until I find 5 which aren't in their list.  This assumes the number of 
questions answered by a single user remains under 5000 (the list size limit 
if I recall) and that there are more unanswered questions than answered 
ones for any given user (so that I don't have to pull too many batches in 
looking for questions).  These limitations might be reasonable, but this 
approach still seems less than optimal.

Any ideas on how to accomplish this?


Someone asked this question a couple years ago with no 
response<http://groups.google.com/group/google-appengine/browse_thread/thread/83012c2aab80fedf/c6b08354b23dc7e9?lnk=gst&q=schema+random+suggestions#c6b08354b23dc7e9>,
 
so I'm hoping some changes have occurred in the mean time to make this 
possible.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/SId0PjB1xtcJ.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to