I have a family tree that users will be added to where they can invite other members of their family.
What I am trying to do is create a smart relationship, where if I invite my son, once I specify he is my son, then the system should automagically know that I am his father.
I figure the only way to do this is to enforce genders on all user records, which is fine.
I also have the following models:
has_one family_tree. Each FamilyTree
So whenever a user joins a family_tree, a
membership is created for them on that FamilyTree.
What I am trying to figure out though is, how do I handle the two-sided relations.
User A adds
User B. I was thinking of creating a new model called
Relationships that would perhaps look like this:
But the issue with this, is that each record doesn’t tell you exactly what’s what. i.e. it doesn’t tell you how that
user1 is the father of
user2, etc. So it would be dependent on the code to know that the relation is always going from the direction of
How do I avoid this problem altogether or figure out an alternative way to represent/think about this issue?