parent 和 child 实体在 GAE 中有什么好处?

What is the benefit of parent and child Entity in GAE?

我如何知道我正在创建的实体是否应该是 child 实体?

DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Entity E = new Entity("Person",52);
E.setProperty("FirstName","Jack");
E.setProperty("LastName","Patrick");
E.setProperty("Gender","Male");
ds.put(E)

现在我有一个名为 User 的实体,如果我将 User 创建为 Person 的 child 有什么好处?

Ancestor-queries 是强一致的(而全局查询,不指定祖先,只是 "eventually consistent")。此外,交易只允许在"entity groups"之间进行,这意味着一个或多个具有共同祖先的实体。

因此,当且仅当您打算在事务中使用它,或者需要能够以高度一致的方式查询它时,您才应该为实体指定 parent。如果两者都不需要,那么避免 parent 可以节省您的时间和资源。