In Datastore, one would use Namespaces to create a multitenant structure.
Example:
Let's say you want to create a social network, like Facebook, but simplified. You'd have users, posts, and comments.
Entities
Namespace
Instead of declaring a 'post' entity as a child of 'user' entity, you can assign a namespace (user-ID) to the 'post'.
In terms of data structure, it might seem there's no difference, but in terms of performance, it does. When you declare an entity as a child of a parent, Datastore will need to store all children together and assure consistency of data within that parent. When you assign a namespace to an entity, it can distribute the data and doesn't guarantee absolute consistency.
That's why Datastore limits to 1 write per second (on average) within each Parent, but doesn't impose write limits within a namespace.
What does 'Consistency' mean?
In this example, let's say Jack published a post right now. Mary and John are his friends. If Mary and John access Jack's posts right after Jack posts, is it 100% guaranteed that both will see this new post?
- If the post is a child of user (Jack), they will.
- If the post is in the user (Jack) namespace, it might not be true at a given point of time; eventually, both will see the post, but it might take some time for the change to propagate.