qualified relationships in datomic

风流意气都作罢 提交于 2019-12-22 04:37:12

问题


In a relational DB, I could have a table Person and a table Hobby. Every person can have zero, one or more hobbies, and I also want to record, say, the priority of those hobbies for every person.

I could create a relationship table with the 2 foreign keys PersonFK and HobbyFK, and one plain column Priority.

In datomic, to model a simple n:m relationship (without the priority), I'd probably create an attribute of type Reference with cardinality Many, that I'd use for Person entities.

But how would I go about qualifying that relation to be able to store the priority? Would it have to be done analogously to the relational case, i.e. by creating a new entity type just for that relation? Or is there any better way? Using some meta data facility or something?


回答1:


A similar question was asked on the Datomic mailing list a few days ago:

https://groups.google.com/d/topic/datomic/7uOl-TISdxA/discussion

In summary, the answer given there is that you are right: you need to create a relation entity on which to store the extra information.



来源:https://stackoverflow.com/questions/12444214/qualified-relationships-in-datomic

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