For new projects, software architects have to decide what database to use. This is a more significant decision than that of which frontend or backend framework to use. They have to choose between NoSQL and SQL databases.
Let’s first take a look at a NoSQL database. You’ve probably heard of MongoDB.
MongoDB is a very popular database that follows the NoSQL design for storing data. Its referred to as a Non-relational database. The stored data is in JSON form, and every entry is an object. It does not have a fixed structure like its counterpart, SQL.
SQL is probably the most used database type worldwide; it uses tables and primary(unique) keys to make relations between data. It has a fixed structure of tables, so you cannot use it to store unstructured data.
MySQL is one of the most popular SQL database management systems. We will be using it in our further discussions.
MongoDB is an open-source database developed by MongoDB, Inc.
It was designed to store flexible data. Take, for example, storing a user’s account details. You might just have a username and email initially. But, later, you might want to add a profile picture or social media details.
With MongoDB, you can easily add these extra fields and changes. If you used an SQL database, you would have to recreate tables, remap relations, etc.
Most NoSQL providers are “Schema less” or “Schema Later” databases. This is helpful at the start when you do not have a fixed schema design in mind.
MongoDB allows you to make frequent changes with no hassle. Many startups like DevRev use NoSQL for this very reason.
Discord also uses MongoDB for flexibility.
SQL and NoSQL use different methodologies or approaches to store data.
MySQL(SQL) uses tables to store data. Every column denotes attributes, and every row represents a data point.
MongoDB uses Collections, which are analogous to tables. A Collections consists of documents containing the JSONs used to store all the information.
containing the JSONs used to store all the information.
A table vs. A JSON
The architecture of any modern relational database is founded on ACID properties.
A → Atomicity: A transaction is an atomic unit of processing; it should either be performed in its entirety or not.
C →Consistency preservation: Consistency is a property ensuring that only valid data following all rules and constraints are written in the database. A consistent transaction will not violate integrity constraints placed on the data by the database rules.
If a transaction is completely executed from beginning to end without interference from other transactions, it should take the database from one consistent state to another.
I →Isolation: A transaction should appear as though it is being executed in isolation from other transactions, even though many transactions are executing concurrently. That is, the execution of a transaction should not be interfered with by any other transactions executing concurrently.
D →Durability: The changes applied to the database by a committed transaction must persist in the database. These changes must not be lost because of any failure.
NoSQL databases follow the principle of CAP.
C →Consistency Every read receives the most recent write or an error
A →Availability Every request receives a (non-error) response — without a guarantee that it contains the most recent write
P →Partition tolerance The system continues to operate despite an arbitrary number of messages being
MongoDB is thought more of a query-time processing structure. SQL, on the other hand, is a Store-time processing structure
There are situations that will force you to choose one over another. If you have a large amount of unstructured data, you are out of options and will have to go with MongoDB, as it is the only option capable of handling such requests.
Understanding the main implications will you make your choice easier.
Simple 1:N queries ( like search, update, or join) take far longer in MongoDB(NoSQL)to complete. This happens due to indexing.
In a relational database, as everything is rigid, the indexing is orderly. This makes the database extremely fast as it can accurately predict where the entry lies on memory.
SQL databases, in general, can be scaled only vertically. i.e., You will have to add more memory, disk space, or computation to an existing server. It becomes very costly over large data volumes.
MongoDB, on the other hand, can be easily scaled horizontally, as it is primarily designed for resiliency. Using Sharding, you can add a new server instead of upgrading the server configuration. This is called horizontal scaling, which is much cheaper because a cluster of low-cost commodities outperforms high query volumes.
Real-world applications need to process their data to perform analytics. Applications need insights on user behavior, usage, etc. SQL and NoSQL allow you to do this in their own ways.
In SQL databases, you can use server-query-language to query. SQL is tried and tested, developer-friendly, and has advanced features like JOIN, Merge, Filter, etc., to carry out analytics.
MongoDB databases do not support SQL Querying. They have basic Document filtering and querying. This tool is nowhere as robust as querying in SQL.
Furthermore, due to the distributed structure MongoDB, it simply cannot run Complex functions like Joins. While this may immediately disqualify it as an available option, there are many workarounds to get SQL-like features.
One easy option is to transform MongoDB data into a SQL data warehouse. Once it is changed, we can access all the analytics features that SQL has to offer.
You can do this by using ETLs (like Panoply or Xplenty)
ETL (Extract, Transform, Load) tools will help you collect your data from APIs and file transfers (the Extract step). Then it will convert them into standardized analytics-ready tables (the Transform step). And finally, put them all into a single data repository (the Load step) to centralize your analytics efforts.
Choosing a Database requires a thorough investigation of what is precisely needed. Here are the key takeaways —
Start with MongoDB if your data requirements are not defined and can still be updated. SQL is a rigid tool
SQL has better performances than MongoDB during reading and comes with a lot more built-in analytics features
MongoDB can be transformed into SQL-like databases but requires proper schemas.

