For real you aren't just getting us to do your homework? This is a very common question in Comp Sci Classes. Just in case this is just logic in a mish mash of PHP, python, and java syntax J $RandomNumberOne = RND(1,100000000000000) // we have lots of questions Array($AnsweredQustions) = Query While ( $RandomNumberOne iscontainedin $AnsweredQustions ) { $RandomNumberOne++ } Fetch_QuestionByID($RandomNumberOne) /////////////// If you need it to be more random take the random number and pick a number half way between it and the max rather than just incrementing. From: google-appengine@googlegroups.com [mailto:google-appengine@googlegroups.com] On Behalf Of DurhamG Sent: Thursday, January 12, 2012 7:36 PM To: google-appengine@googlegroups.com Subject: [google-appengine] Data schema for showing a user 5 random questions they haven't already answered? 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-th e-google-app-engine-datastore> (which uses a > query filter), and I've seen the presentation <http://www.google.com/events/io/2009/sessions/BuildingScalableComplexApps.h tml> 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/83012c 2aab80fedf/c6b08354b23dc7e9?lnk=gst&q=schema+random+suggestions#c6b08354b23d c7e9> , 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.
-- 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-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.