What is the Google App Engine Datastore "parent key"?

What is the "parent key" used in the Google App Engine Datastore classes and what is it used for?


source to share

3 answers

Reading more will probably help you.

From the documentation:

To assign a parent, use the parent argument for the class model when creating the child. The value of this argument can be the parent object itself or its key; you can get it by calling the parent entity key () method. The following example creates an object of the form Address and shows two ways to designate the Entity of an employee as his parent:

#Create Employee entity
employee = Employee()

#Set Employee as Address entity  parent directly...
address = Address(parent=employee)

# ...or using its key
e_key = employee.key()
address = Address(parent=e_key)

# Save Address entity to datastore




An object in a data store can optionally have a parent object; "parent key" is the key of the parent object.

Initially (and yet in a master-slave datastore) transactions were only possible between objects in the same entity group, which is a collection of objects with a common ancestor object. Transactions with group entities are available in HR data warehouse, although they are available for only five groups of entities.

Thus, parent objects are used to create groups of entities that will be used in transactions. Note that having groups of objects that are too large can seriously hinder the write speed because when writing to one object in a group, the entire group is essentially locked; trying to make too many records in the same entity group results in datastore permission exceptions.



Parent keys are used to create groups of entities. When one or more data warehouse objects share an ancestor, they are said to be part of the same group of entities.

This comes into play in terms of how you write transactional data warehouse operations. If all the objects to be changed are not part of the same group of entities, you must indicate that a transaction is taking place between groups.



All Articles