Discussion:
[mongodb-user] Why is denormalized data nested in mongodb?
Samuel Chow
2018-12-07 21:06:26 UTC
Permalink
So I've been doing some research on creating the correct data model for my
application.

Something I noticed in examples has been that when data is denormalized it
is usually nested in the data record.

Example:

{ // Build Info
_id : ObjectID("M"),
date : "2018-12-07",
buildVersion : "0.1.0.0"
}

{ // Test Data
_id : ObjectID("A"),
buildRef : {
_id : ObjectID("M"),
buildVersion : "0.1.0.0"
},
data1 : 1.0
data2 : 2.0
}

buildRef key is used contains another key/pair.

I was thinking if I was to search Test Data using a Build Info
ObjectID("M") wouldn't querying be inefficient since mongodb needs to go
one layer deeper into the nested record?

Could this be a bit more efficient?

{
_id : ObjectID("A"),
buildRef_id : ObjectID("M"),
buildRefBuildVersion : "0.1.0.0",
data1 : 1.0
data2 : 2.0
}

I'm sure there is a reason the examples are written this way. Maybe mongodb
doesn't care and its just as efficient. Any enlightenment would be great.
Thanks!
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/ad3483c2-6f68-44ac-b8cc-5378e5dc6df9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...