google app engine - Should datastore entity always have parent -


one of thing of having parent datastore entity that, can perform transaction on entity.

https://cloud.google.com/appengine/docs/python/datastore/transactions

however, don't need perform transaction on entity.

i wondering, ok not having parent entity? as, make code simpler , easy maintain?

is there side effect of not having parent entity?

one of concern of not having parent, eventually consistency. after write operation, want read operation able fetch latest written value. i'm using user.get_or_insert write (possible read), , user.get_by_id read only.

i want after execute user.get_or_insert, , next request user.get_by_id return latest value. wondering, achieve strong consistency, parent key important thingy?

i wondering, ok not having parent entity?

absolutely, yes, need consider how reading , writing data don't run gotchas down line.

if don't have ancestor, queries have eventual consistency, may find results don't match query. remember, can use cross entity group ('xg') transactions can involve 5 entity groups (an entity without ancestor defines own entity group), allows flexibility.

on other hand, can @ time still strong consistency, using get-by-key, regardless of whether entity has ancestor.


Comments