NoSQL basics with introduction to MongoDB

Uditha Ekanayake
3 min readMar 17, 2022

NoSQL is a family of non-tabular databases that store data in a different way than relational databases like SQL. Relational databases primarily store data in “relations” which are a structure that is understood in high level as a table. NoSQL databases on the other hand uses different methods to store data and depending on those models, they are divided in to different groups.

  • Document
  • Key-value
  • Wide-column
  • Graph

These databases are highly scalable and flexible.

Document databases
Stores data in a similar manner as JSON (JavaScript Object Notation). Documents contain fields and their respective values. Values can be of different types such as booleans, ints and strings.

Key-value databases
Data is stored as key value pairs in the database. Each item has it’s own unique key.

Wide column stores
Stores data in tables, rows and dynamic columns.

Graph databases
Graph databases store data in nodes and edges. Nodes contain data and edges contain information about nodes and their relationships.

NoSQL databases are widely used in every industry and are highly scalable and easy for development.

CAP theorem

CAP theorem also known as the Brewer’s theorem specifies that any distributed database system can provide two of the following 3 guaranties.

  1. Consistency
  2. Availability
  3. Partition tolerance

“In normal operations, your data store provides all three functions. But the CAP theorem maintains that when a distributed database experiences a network failure, you can provide either consistency or availability.

It’s a tradeoff. All other times, all three can be provided. But, in the event of a network failure, a choice must be made.” — https://www.bmc.com/blogs/cap-theorem/

MongoDB

MongoDB is one of the most widely used NoSQL databases in the world. MongoDB is easy to use and supports multiple platforms. It is a fully cloud based distributed database. It uses document database model and provides highly scalable and change friendly design with powerful querying and analytical capabilities.

Benefits of MongoDB

  • MongoDB is open source
  • Flexibility of document schemas
  • Wide support
  • Scalable and change friendly
  • Powerful querying and analytical capabilities
  • Horizontal scaling
  • Simple installation
  • Cost effective

MongoDB is a powerful document based database and it has many advantages. MongoDB can be accessed through https://www.mongodb.com/

--

--