MongoDB Alternative Design

db.firsts.findOne()
{
    "_id" : ObjectId("..."),
    "Seconds" : [
        { $ref : 'seconds', $id : <idvalue> },
        { $ref : 'seconds', $id : <idvalue> },
        { $ref : 'seconds', $id : <idvalue> }
    ]
}

db.seconds.findOne()
{
    "_id" : ObjectId("..."),
    "Second Name" : "value",
    "Thirds" : [
        { $ref : 'thirds', $id : <idvalue> },
        { $ref : 'thirds', $id : <idvalue> }
    ]
}

db.thirds.findOne()
{
    "_id" : ObjectId("..."),
    "Third Name" : "value"
}
Topics: MongoDB

Related Code Examples