在我正在开发的应用程序中,我有两个紧密相关的实体(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.
更多推荐
发布评论