I have a few questions about MongoDB. I've been using MongoDB since a few days ago and I'm very confused because I have experience only in relational databases such as MySQL and PostgreSQL.
My first attempt using Mongo went wrong: I tried to put all the entities as embedded documents in a single collection. The problem here is that one of these entities had a lot of millions of documents. Another problem is the dificulty of getting some data in that structure. So I designed again my "schema" separating some entities as differents collections with related id's, like a primary key in a RDBMS. This helps me a lot to do some "joins", because when the data is embedded, $lookup
returns the whole document (its parent) and not only the ones who matches in the localField
and foreignField
. This is very strange to me, but I had a lot of flexibility to make querys and get only the data that I needed to.
So, my questions is: if I have different collections, one for each entity and references among them, what's the difference between a RDBMS and MongoDB? Is Mongo (in this context) more efficient than a RDBMS (knowing that some of the entities grows in millions of data every day)?
Thanks!