Many-to-Many Relationship (with properties) in Google App Engine for Java

倾然丶 夕夏残阳落幕 提交于 2019-12-01 20:16:36

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3066891/many-to-many-relationship-with-properties-in-google-app-engine-for-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!