我应该把用户放在祖先路径还是分开? [英] should I put the user in the ancestor path or separately?

查看:72
本文介绍了我应该把用户放在祖先路径还是分开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用应该包含多个用户,每个用户都有一个对象列表(只有一个用户拥有该对象)。
我的问题是:将实体用户引用其对象的Id,还是应该将用户作为对象的祖先,最好?请注意,我只是从nosql和datastore开始!

解决方案

您应该选择哪种方法主要取决于一致性模型强大vs最终)你需要为你的实体。在Google Cloud Datastore中,实体组(实体及其后代)是具有强一致性,事务性和局部性的单元。

有关主题< href =https://developers.google.com/appengine/docs/python/datastore/structuring_for_strong_consistency =nofollow>此处和这里



还有一件需要考虑的重要事项。如果您建模用户和对象之间的父子关系,则父对象将成为对象关键字的一部分,因此,如果稍后您将更改对象的所有者,则您的关键字将以不同的对象结束。


My app should contain several users, each of them having a list of objects ( only one user own the object ). My question is : Would it be better to put an entity User that references the Ids of its objects, or should I put the user as the ancestor of the objects ? Please be kind, I am just beginning with nosql and datastore !

解决方案

Which approach you should choose depends mainly on the consistency model (strong vs eventual) you require for your entities. In Google Cloud Datastore, an entity group (an entity and its descendants) is a unit with strong consistency, transactionality, and locality.

You can read more on the topic here and here.

And there is one more important thing that is needed to take into account. If you model a parent-child relationship between a user and an object, the parent will be part of the object's key hence if you will change the object's owner later, you will end up with different object in terms of its key.

这篇关于我应该把用户放在祖先路径还是分开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆