Skip to main content

MongoDB

What is MongoDB ?

MongoDB is an open source NoSQL database management program. NoSQL is used as an alternative to traditional relational databases. NoSQL databases are quite useful for working with large sets of distributed data. It is a source-available cross-platform document-oriented database program.Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License.MongoDB is a global company with US headquarters in New York City and International headquarters in Dublin.MongoDB offers a Community version of its powerful distributed document database. With this free and open database, download the MongoDB server to secure and encrypt your data and gain access to an advanced in-memory storage engine.

Why Use MongoDB?

MongoDB is built on a scale-out architecture that has become popular with developers of all kinds for developing scalable applications with evolving data schemas. As a document database, MongoDB makes it easy for developers to store structured or unstructured data. It uses a JSON-like format to store documents. This format directly maps to native objects in most modern programming languages, making it a natural choice for developers, as they don’t need to think about normalizing data. MongoDB can also handle high volume and can scale both vertically or horizontally to accommodate large data loads.MongoDB was built for people building internet and business applications who need to evolve quickly and scale elegantly. Companies and development teams of all sizes use MongoDB for a wide variety of reasons.

How MongoDB Works?

Working with MongoDB NoSQL database is much easier than working with any relational database. There are no tables in MongoDB. All the data is stored in JSON format,i.e. key-value pairs. In JSON, we define a unique key with a value associated with it. These key-value pairs are stored in a document, which in turn is stored in a collection. A collection in MongoDB can have any number of documents and such documents can have any number of key-value pairs. As I mentioned earlier, data in the MongoDB database is stored in BSON. BSON is nothing but extended JSON. It supports more data types than JSON. We store anything like, string, integer, boolean, double, binary data, object, array, javascript code and many more. These documents are grouped inside a collection. A collection can be equivalent to a table in a relational SQL database. A collection always exists in a database and there is no pre-defined structure of a collection. In SQL, the database contains tables and in MongoDB, the database contains collections.

Important Terms in MongoDB

  • Document: A document is a record in MongoDB where data is stored in key-value pairs.
  • Collection: A collection is a group of documents.
  • Database: A database is where all the collections are present.
  • Key-value pairs: Data in MongoDB is stored in JSON format. JSON stores data in key-value pairs.
  • JSON: It is a data-interchange format we use in MongoDB to store data.
  • BSON: BSON is extended JSON which supports a variety of data types.
  • _id: _id is a field auto-generated whenever a document is created. The value of _id is unique.

Advantages of MongoDB

  • Flexible document schemas.
  • Code-native data access.
  • Change-friendly design.
  • Powerful querying and analytics.
  • Easy horizontal scale-out.
  • Structure of a single object is clear.
  • Handle large volumes of data at high speed with a scale-out architecture.
  • Store unstructured, semi-structured, or structured data.
  • Enable easy updates to schemas and fields.
  • Be developer-friendly.
  • Take full advantage of the cloud to deliver zero downtime.

Disadvantages of MongoDB

  • MongoDB uses high memory for data storage.
  • There is a limit for document size, i.e. 16mb.
  • There is no transaction support in MongoDB.
  • Not all NoSQL databases contemplate the atomicity of instructions and the integrity of the data. They withstand what’s know as eventual consistence.
  • Compatibility issues with SQL instructions. New databases use their own characteristics in the query language and they’re not yet 100% compatible with the SQL used in relational databases. Support for work query issues in a NoSQL database is more complicated.
  • Lack of standardizing. There are many NoSQL databases and there is still no standard like the ones that exist in relational databases. An uncertain future is predicted for these databases.
  • Cross-platform support. There are still many improvements to be made on some systems so that they can run on non-Linux operating systems.
  • They usually have not-really-useful management tools or console access.