The Google App Engine Datastore allows each entity to have a parent entity, essentially a way to form an entity hierarchy. For example, an Employee
can be addressed as:
Company#521/Department#5/Employee#3
The entity id is only unique among entities with the same parent, so the full entity path is required to uniquely address it.
So far, so good.
But when should I model a parent-child relationship this way, rather than relying on a basic reference property within an entity, as I would in a traditional database?
The only reason I can think of is to get around the lack of joins in a Datastore query. I can only filter a query using properties from the entity whose kind I am retrieving -- and by any entity that is a parent at any level in the entity's hierarchy.
Any other reason to use this feature?
The Datastore documentation says that entities that belong to the same hierarchy are treated as an entity group, and that entities in the same entity group have serialized write access. What exactly does that mean? Does it mean that if one thread of my app is updating Department#5
, another thread that is writing to Employee#3
will have to wait for this update to finish?
Thanks!