Mongodb – document based database. NoSql db means not only sql database.It is completely written in C++.
MongoDB is a cross-platform, document-oriented database that provides, high performance, high availability, and easy scalability. MongoDB is basically created to handle a huge amount of data
Mongodb works on the concept of collection and document.
- Database: it is a physical container for collection. In this, each database has its own files on the file system.
- Collection: It is a group of documents and documents is the same as the table in RDBMS. The schema is not required for the document as it is required for a table in RDBMS. Each document in the same database may have different fields.
- Document: it is a set of key-value pairs. It is having a dynamic schema which means it may have different fields or structure. It is equivalent to a row of the table in RDBMS.
- Fields: – Field is equivalent to columns in RDBMS table.
Installation link is this. Download MSI file from here. Get the MSI package from this and install after going to command prompt and paste below command.
To interact with DB you can use robomongo link Is having GUI to interact with the database .
NoSQL and MongoDB
As a developer, we mainly interact with class and object and sometimes we use different OOPs concept so sometimes it’s hard to map object to the table in the database. when we use Mongo there is no schema so we can add anything.
In mongo document present in the same collection may be different so we have to not bother about the schema. But as in RDBMS, we have schema define for a table.
Scalability achieved using Mongo By following the way
- No Schema: – schema is not present so is easy scalability achieved.
- Single document writes scope: – it means that no relationship presents between the document and so if we want to write or update document operation will perform on a single document only which is independent.
- Capped collection: – Mongo offers a capped collection it means a collection have fixed size and automatically overwrite older document. Also, it is having a fixed size so it’s not spending the time to allocate space for the new document. When to use this when you want to insert many documents at once then you should go for capped collection.
Benefits of NoSQL database: –
- Schema-less document structure: – it means you can modify your schema while writing data into a database.
- Query database without complex joins: – it means you can perform complex joins by using an embedded document.
- Easily model your data into an object by using Object-oriented API’s