Quantcast
Channel: Mockaroo Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 2665

Best approach to represent bi-directional relationships?

$
0
0

How best to represent the following:

// array of parent objects
[{
    "id": 1,
    "name": "Bob Smith",
    "children": [ 3 ]
},
{
    "id": 2,
    "name": "Jane Smith",
    "children": [ 3 ]
}]

// array of children objects
[{
    "id": 3,
    "name": "Martin Smith",
    "parents": [ 1,2 ]
}]

The idea here that we'd need at least 2 schema, parents and children. But there is a interdependency. Elements in the children array should exist as valid children id's. Conversely, elements in the parents array should exist as valid parent id's.


Viewing all articles
Browse latest Browse all 2665

Trending Articles