Google App Engine for Java 中的多对多关系(带有属性)

发布于 2024-09-06 06:34:44 字数 488 浏览 5 评论 0原文

我从官方文档 对于无主关系,应用程序必须在关系的任一侧使用 Key 对象集。这是完全有道理的。

不过,经过多年的 RDBM 风格编程,我对如何对这种关系本身的属性进行建模感到非常困惑。例如,如果我的多对多关系中有实体 CategoryEntry,并且希望保留 dateAdded 属性,或者某些属性仅当关系双方都已知时才相关的其他数据。

我想可以创建第三个类: CategoryEntry 来链接这两个类,但这看起来像是一个拼凑。

模拟这种情况的建议方法是什么?

I understand from the official documentation on unowned relationships that the app must use sets of Key objects on either side of the relationship. This makes perfect sense.

Coming from many years of RDBM-style programming, though, I'm pretty confused about how I can model properties of that relationship itself. For example, if I have entities Category and Entry in my many-to-many relationship and would like to persist a dateAdded property, or some other data that are only relevant when both sides of the relationship are known.

I suppose it would be possible to create a third class: CategoryEntry that links the two, but this seems like a kludge.

What is the proposed way to model this kind of situation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽清梦 2024-09-13 06:34:44

您所描述的“关系表”是与属性建立关系的标准解决方案(无论是在 RDBMS 领域还是在 App Engine 数据存储区中)。这不是一个拼凑,因为当关系具有除其存在之外的属性时,它需要某个地方来表示它。

A 'relation table' such as you describe, is the standard solution - both in the RDBMS world and in the App Engine datastore - to having a relation with properties. It's not a kludge, because when the relation has attributes other than its existence, it requires somewhere to represent that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文