Contents
In which of the following cases should you not embed one document into another in MongoDB?
When the field is rarely updated. If the name of a group is rarely updated in the collection. For example, if the group name Developers required to be updated to Web Developers for the entire Users collection often, then embedding UserGroups is not suitable.
What MongoDB is not good for?
MongoDB, unfortunately, does not support transactions. So if you need to update more than one document or collection per user request, don’t use MongoDB. It may lead to corrupted data, as there is no ACID guarantee. Rollbacks have to be handled by your application.
Which is the one to many relation in MongoDB?
So, this is a one to many relation. It requires 2 collections. For small one to few (which is also one to many), relations like blog post to comments. Comments can be embedded inside post documents as an array. So, if it’s truly one to many, 2 collections works best with linking. But for one to few, one single collection is generally enough.
Why do you need to normalize data in MongoDB?
Because MongoDB documents have structure, and because you can efficiently query within that structure (this means that you can take the part of the document that you need, so document size shouldn’t worry you much) there is no immediate need to normalize data like you would in SQL.
Can you use reference in another document in Mongo DB?
Yes, we can use the reference in the document.To populate the another document just like sql i joins.In mongo db they dont have joins to mapping one to many relationship document.Instead that we can use populate to fulfill our scenario..
What kind of data can you store in MongoDB?
MongoDB can store arbitrary deep nested data structures, but cannot search them efficiently. If your data forms a tree, forest or graph, you effectively need to store each node and its edges in a separate document. (Note that there are data stores specifically designed for this type of data that one should consider as well)