Hi @Soufian_Ta and welcome in the MongoDB Community
!
For the last part of your question, I think you are referring to the equivalent of a “join” SQL operation. The way to do that with MongoDB is with the $lookup aggregation stage.
We usually try to recommend to avoid this kind of operation because they are more resources intensive than a “standard” access to a single document.
Let’s take an example. Let’s say you have a blog like Learn - MongoDB Developer Hub.
In each page of the blog, you present the title of the blog post, the content, the number of likes, the author’s name and thumbnail, etc. In SQL, the author would be stored in another collection. Same for MongoDB actually because maybe you don’t want to duplicate the same data everywhere. But you don’t have to duplicate EVERYTHING from the author collection to serve that page.
In a blog post page, you just need the author’s name and thumbnail. But if you visit the author’s profile page in the blog, you will also find its GitHub account, LinkedIn, date of birth, author’s bio, etc. These fields aren’t served in the blog post page. Only in the author’s profile page.
By just duplicating a small portion of the data (that is very unlikely to change on top of that), you remove the need for a $lookup query and you can just serve the blog post with a single and simple query indexed on the URL slug.
I hope it makes some sort of sense
!
If you want to learn more about data modeling, I recommend reading these blog posts and read more about the design patterns. We have an entire series in the MongoDB DevHub.
We also have an entire training about this in the MongoDB University platform.
Cheers,
Maxime.