Google App Engine for Java中的多对多关系(包含属性) [英] Many-to-Many Relationship (with properties) in Google App Engine for Java

查看:158
本文介绍了Google App Engine for Java中的多对多关系(包含属性)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从官方文档了解应用程序必须在关系的任一侧使用Key对象组的无主关系。这非常合理。

然而,从很多年的RDBM风格的编程中,我对如何模拟这种关系本身的属性感到非常困惑。例如,如果在我的多对多关系中有实体类别条目,并且想要保留一个dateAdded属性或一些其他仅与双方的关系是已知的。



我想可以创建第三个类: CategoryEntry 看起来像一个杂食。



建议如何模拟这种情况? 解决方案

<比如你所描述的'关系表'是标准解决方案 - 无论是在RDBMS世界还是在App Engine数据存储中 - 都与属性有关系。这不是一个混乱,因为当关系具有除存在以外的其他属性时,它需要某处来表示它。


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 ?

解决方案

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.

这篇关于Google App Engine for Java中的多对多关系(包含属性)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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