Now you may or may not have a SQL background
but when I started working with mongodb,
there was one thing which I found kind of hard to wrap my head around. Mongodb is a so-called noSQL
solution because it's basically following an opposite concept or philosophy
than all the SQL based databases do. Instead of normalizing data which means storing it, distribute it
across multiple tables where every table has a clear schema and then using a lot of relations, instead
of doing that, mongodb goes for storing data together in a document
and it also doesn't force a schema on you,
so we got no schemas in mongodb. If we have multiple documents in one and the same collection, they
can have different structures,
that is one thing I mentioned in the last video and this is really important,
this can of course lead to messy data but it's still your responsibility as a developer to work with
clean data and to implement a solution that works
but on the other hand, it gives you a lot of flexibility and flexibility is always good.
You can use mongodb for apps that might still evolve, where the exact data requirements are just not
set yet,
you can get started and you can always add data with more information in a collection in the same collection
at a later point of time.
You also work with less relations,
there are some relations and I have old module where I talk about that
but with these embedded documents which I already showed you, one core thing of mongodb indeed is
that you have less tables, so less collections which you connect but instead that you store data together
and this is where the efficiency is derived from. Since data is stored together,
when your application is fetching data, it doesn't need to reach out to collection A, merge it with
collection B, merge it with collection C, instead it goes to collection A then mongodb has a very efficient
querying mechanism behind the scenes so that it can go through all the data very fast when looking for
a specific document,
so this will be super fast and then it finds that document and it's done,
it doesn't need to do any merging most of the time.
So this is really where the speed, the performance and flexibility comes from
and this hopefully speaks for itself that this can be useful when building applications
and this is also why noSQL solutions and amongst them most of all mongodb, is super popular
for read write heavy applications, applications with a lot of workload, applications that store a lot
of data, let's say smart devices which send some sensor data every second,
for such applications but also for building an online shop or a blog, mongodb is an amazing
solution due to the performance and the flexibility it gives you.