Search code examples
hibernateormibatis

Mutualy owned bi directional relations (friends)


I am writing an ORM. I am curious how friend relations are generally modeled. Are they duplicated relations in a link table with each user an owner of his friend relations, or is there an introduction of a mutually owned relation, where the orm looks up relation links where the relation owner's id can be in the child field of the relation link table?


Solution

  • I've never seen an ORM doing your "mutually owned relation" because it would only work for readonly scenarios but ORM is typically for readwrite. i would model them like this