Javatpoint Logo
Javatpoint Logo

What is MongoDB in MEAN Stack

In our previous module, we had a closer look at the angular and node. Previously, we didn't stored any data on our server. We need to persist data on the server so that our users can load the data whenever they come back to our webpage, even if they come back to it from a different machine.

MongoDB is a type of NoSQL database that stores documents and collections. The documents are equivalent to records, and the collections are what we know as tables in SQL. So, MongoDB is a database that runs on a server. We store application data there like our users, products, and etc. The MongoDB enforces no data schema or relations. So, the individual records can be structured in the way we want.

MongoDB is easily connected to node and express, and that is something great about MongoDB. We can easily add it to a node express backend, not directly to angular.

Overall, MongoDB is a powerful database that we can easily integrate into our node express environment.

We will use MongoDB here because the MEAN Stack is really popular, but we could theoretically swap it for any other database, e.g., MySQL. Now the question is, why are we using MongoDB and what is the difference between MongoDB or NoSQL databases and SQL solutions like MYSQL?

Difference between NoSQL and SQL

S.NO. NoSQL SQL
1. NoSQL is a non-relational or distributed database system. SQL is a relational database system.
2. These databases are very helpful for hierarchical data storage. These databases are not good for hierarchical data storage.
3. Enforce no data schema. Enforce a strict data schema.
4. For complex queries, these databases are not helpful. These databases are very helpful for complex queries.
5. Less focused on relations. Relations are a core feature.
6. Independent documents. Records are related.
7. Great for: logs, orders, messages. Great for: shopping carts, contacts, and networks.
8. This data is horizontally scalable. This database is vertically scalable.
9. MongoDB, CouchDB, etc. MySQL, MSSQL, etc.

Features of MongoDB

These are some of the following features which make important to use it as a database in MEAN Stack:

  • MongoDB support ad hoc queries. Here, we can search by field and range query. MongoDB also supports regular expression searches.
  • MongoDB supports indexing also. So, we can index any field in a document.
  • MongoDB supports Master-Slave replication. In Master-Slave replication, Master performs Read and Writes operation and the Slave copies data from the master that cannot be used for writes.

To learn more about MongoDB, go to the https://www.javatpoint.com/mongodb-tutorial link.

In the next section, we will learn how to set up the MongoDB for our application.






Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA