问题
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