Many-to-Many Relationship (with properties) in Goo

2019-02-24 05:31发布

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条回答
看我几分像从前
2楼-- · 2019-02-24 05:58

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.

查看更多
登录 后发表回答