1

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!

Tomás Juárez
  • 1,517
  • 3
  • 21
  • 51
  • 2
    Doesn't seem to be about PostgreSQL at all really, so untagging – Craig Ringer Jul 25 '17 at 03:49
  • 1
    Seems overly broad. So marking to close as such. If you want answers/advice then I suggest asking "smaller" and more "specific" questions on points of design. – Neil Lunn Jul 25 '17 at 06:43
  • Extending the last comment: The difference is essentially that between relational vs non-relational models/structures/DBMSs. Each of the latter having its particular non-relational aspects for its particular specialized queries & performance. In this case, the non-relational product is MongoDB. Compare to [How to convert an existing relational database to a key-value store?](https://stackoverflow.com/q/45294578/3404097). See [this & its links](https://stackoverflow.com/a/44327398/3404097) re relational vs not. – philipxy Jul 26 '17 at 02:48

0 Answers0