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

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


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

{ // Test Data
_id : ObjectID("A"),
buildRef : {
_id : ObjectID("M"),
buildVersion : ""
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 : "",
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.
You received this message because you are subscribed to the Google Groups "mongodb-user"

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.
Continue reading on narkive: