MongoDB

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.

  1. Database: it is a physical container for collection. In this, each database has its own files on the file system.
  2. 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.
  3. 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.
  4. 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.

C:\Program Files\MongoDB\Server\4.0\bin\mongo.exe

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.

{x: 1,tags:[‘abc’,’xyz’]};

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

  1. No Schema: – schema is not present so is easy scalability achieved.
  2. 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.
  3. 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:

  1. Schema-less document structure: – it means you can modify your schema while writing data into a database.
  2. Query database without complex joins: – it means you can perform complex joins by using an embedded document.
  3. Deep query ability which is supported by JavaScript infrastructure.
  4. Easily model your data into an object by using Object-oriented API’s

You may also like...

3 Responses

  1. April 29, 2019

    […] Db- mongoDb and […]

  2. April 29, 2019

    […] can use index to increase performance. In mongodb we have B-Tree indexes. If we don’t provide index then it will perform collection scan means it […]

  3. May 1, 2019

    […] database, we have a primary key and foreign key like this in MongoDB we have references in mongo means we can reference one document to another […]

Leave a Reply

Your email address will not be published. Required fields are marked *