It's a really good question and perhaps someone with more db experience than me will write some kind of tutorial about planning your db structure for GAE...
The biggest question I wished I'd asked myself before designing my app is: "what sorts of models will I want to update together in transactions?" Because in Datastore you can only run transactions on entities in the same entity group (meaning each entity is an ancestor/ child of the others). So if you need certain operations to maintain consistency, for instance "add new Turn entity, update Game's current_player" you will need to plan that ahead of time (perhaps assigning each Turn as a child of the Game it takes place in). Other than that, just remember that writing to Datastore is very expensive (as is fetching large numbers of entities from a query) - you will want to figure out ways to retrieve entities by key as much as possible. Good luck, Tony On Jun 9, 1:47 pm, n8gray <[email protected]> wrote: > Hi everybody, > > I'm about to start working on an AppEngine backend for an iPhone game > I'm developing. It's a simple board game, with 2-4 players who each > take turns making plays. Originally I had planned to set up a LAMP > server for my project, but AE has changed my plans (for the better!). > I've never written database code before but I've read up on the basics > of database design, and I came to the conclusion that I would need a > DB schema with tables something like this: > > Players: username, email, userid, ... > Games: gameid, time_started, current_player, is_finished, ... > Players2Games: userid, gameid, score, ... > Turns: userid, gameid, timestamp, turn_number, play, turn_score, ... > > It seems clear, however, that Datastore is not a traditional database > and perhaps my schema needs to be revisited. Is it still necessary or > advisable to use a table like Players2Games in order to represent many- > to-many relationships? What should my roots and parent/child > relationships be? > > Typical queries will be (unsurprising) things like: > get all games for player x > get all players for game x > get the scores of all players in game x > get any turns in game x that have occurred since time t > > Any advice, or pointers to articles/posts/documentation are > appreciated! > > Thanks, > -n8 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
