You could do something like this (I'm writing python instead of java but you get the idea):
class User(db.Model): matchesInitiated = db.ListProperty(db.Key) matchesAttempted = db.ListProperty(db.Key) class Match(db.Model) interesting_property = db.StringProperty() The properties on User contain db.Keys of Match entities that the User relates to. When you want to get all matches for a user, you just merge the two properties into one list of keys and db.get (list_of_keys). No queries, even. On Jun 22, 6:31 pm, tiburondude <david.jonathan.nel...@gmail.com> wrote: > Hi, > > I have an app with two entities that need (maybe) to interrelate in > the typical sql join sense. > > Users > --------- > userId Long > > Matches > initiatingUserId Long > attemptingUserId Long > matched boolean > > From my UI I can get the data populated properly but I end up with > this in one row: > > initiatingUserId = 1 > attempingUserId = 2 > matched = true > > What I want is when user 1 goes to this section of the app, to get a > list of all records with matched = true, where the currently logged in > user is in EITHER initiatingUserId OR attemptingUserId. This can't be > done in the sql sense using a logical OR, since that's not supported > in the datastore since it doesn't perform well. > > Of course I can do two queries and join the dataset, but this > introduces some serious pain in the workaround regarding paging on a > large dataset. Not to mention two queries per request just sounds > slow/wrong. > > I watched the excellent video from google IO 2009 that instructs us to > think of these things as "group membership queries", and to do "venn > diagram self joins". > > So I was thinking the solution may be to remodel the entities like so: > > - Remove the Matches entity completely > - change the Users entity to this: > > Users: > --------- > List<int> initiatingUserIds > List<Int> attemptingUserIds > > I'm struggling to write the query that would then retrieve this data. > > Anyone have any ideas on this design? > > Thanks a bunch! > David --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---