Ok maybe I don't absolutely need it to delete a team but what about...

1) when I'm creating a new game - team1 or team2 could be deleted as
I'm creating a new game, then the game will have a team that does not
exist

OR

2) for arguments sake, I need the deletion of a team (and all the
games it's in) to be atomic.  What you're suggesting can fail at
anywhere between 1 and 4.


On Apr 12, 4:35 pm, djidjadji <[email protected]> wrote:
> Start with answering the question: Do I need a transaction?
>
> I don't think you need it to delete a team.
>
> Every Team and every Game are root entities, no child objects.
>
> When you want to delete a Team
>    1) find all Games that have the Team in attribute team1
>    2) delete these Games, maybe delete in groups of 10 to 20 per request
>    3) find all Games that have the Team in attribute team2
>    4) delete these Games, maybe delete in groups of 10 to 20 per request
>    5) delete the Team object
>
> You can use the method from [1] to delete the Games
>
> [1]http://code.google.com/appengine/articles/update_schema.html
>
> 2009/4/13 ae <[email protected]>:
>
>
>
> > Does anybody else find transactions very restricting?  How do I solve
> > this problem?  Here is my data model...
>
> > Team(db.Model):
> >  name = db.StringProperty()
>
> > Game(db.Model):
> >  team1 = db.ReferenceProperty(Team, collection_name='game1_set')
> >  team2 = db.ReferenceProperty(Team, collection_name='game2_set')
>
> > ... if I delete a team, I want to delete all the games associated with
> > it as well so I need to put the delete operation in a transaction.
> > But how would I setup the entity group?
>
> > setup 1) Team as parent of Game - but there can be only 1 parent and
> > team1 and team2 should both be parents - DOESN'T WORK
> > setup 2) Game as parent of Team - then that would mean each team can
> > only play 1 game?  DOESN'T WORK
> > setup 3) create a 3rd entity and let that be the parent of both Team
> > and Game - but then all teams and games would be in the same entity
> > group - is this my only option?
>
> > Thanks.
>
>
--~--~---------~--~----~------------~-------~--~----~
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