Google App Engine:两个紧密相关的实体应该合并吗?(Google App Engine: Should two tightly related entities be combined

系统教程 行业动态 更新时间:2024-06-14 16:57:39
Google App Engine:两个紧密相关的实体应该合并吗?(Google App Engine: Should two tightly related entities be combined?)

在我正在开发的应用程序中,我有两个紧密相关的实体(EntityA,EntityB)。 在没有EntityA的情况下永远不会访问EntityB,但是实体A通常在没有实体B的情况下访问。此外,EntityB可能非常大,而EntityA的大小适中。

将EntityB添加到EntityA(作为结构化属性/复制字段)是否有任何不利之处? 从而增加了EntityA的大小,并消除了EntityB。 或者我应该只使用EntityA中的密钥属性来引用EntityB,并在需要EntityB时使用额外的get?

In an application I'm developing I have two entities that are tightly related (EntityA, EntityB). EntityB is never accessed without EntityA, but EntityA is often accessed without Entity B. Also, EntityB can be very large, while EntityA is moderately sized.

Is there any disadvantage to adding EntityB to EntityA (as a structured property/copying the field)? Thereby increasing the size of EntityA, and eliminating EntityB. Or should I just use a key property in EntityA to reference EntityB, and use an extra get whenever EntityB is needed?

最满意答案

如果每个实体A最多只有一个实体B,则可以使实体B成为实体A的子实体。这样可以很容易地检索它 - 您甚至不必在父实体中引用其键。

如果您经常需要两个实体而没有另一个实体,则没有理由将它们组合在一起。 加载比您需要的数据更少的性能损失。

If there is at maximum only one Entity B for each entity A, you can make entity B a child of Entity A. This makes it easy to retrieve it - you don't even have to reference its key in the parent Entity.

There is no reason to combine two entities if you often need one without the other. There is a small performance penalty from loading more data than you need.

更多推荐

本文发布于:2023-04-13 12:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/288a738a89e7eadaa8f38cdb80fe3502.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   紧密   两个   Engine   Google

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!