In NoSQL databases there is almost never a single most model that is most efficient for all use-cases. That is because in NoSQL you will often have to modify and expand you data model for each use-case you want to implement in your app. For a good introduction to the topic, I recommend reading NoSQL data modeling and watching Firebase for SQL developers.
That said, at its most basic you have a bidirectional many-to-many relationship, which could be modeled as:
users
parent: {...}
child1: {...}
child2: {...}
parents: /* contains the parent for each user */
child1: "parent",
child2: "parent"
children: /* contains the children for each user */
parent:
child1: true,
child2: true
The fact that a user can only have a single parent is modeled here by having a single value for each node under parents
. The possibly multiple children per user is modeled as a collection for each node under children
. That collection is modeled as a so-called index: a collection of String: true
pairs, where the value (true
) is a meaningless marker.
This uses concept from a few other answers, so I'll link you there for more information: