DEV Community

Cover image for Will NoSQL Databases Replace SQL Databases in the future
Samuel Abolo
Samuel Abolo

Posted on

Will NoSQL Databases Replace SQL Databases in the future

WILL NOSQL REPLACE SQL DATABASES IN THE FUTURE

In this article, we will be discussing The following

  • What SQL is (Pros and Cons)
  • What NoSQL is (Pros and Cons)
  • When to use SQL and to use NoSQL (ACID vs BASE)
  • Will NoSQL replace SQL in the future? Why (not)?
  • What the future of databases looks like (Databases supporting both SQL and NoSQL databases)

What is SQL?

An Example of an SQL query

SQL stands for the structured query language. It’s the standard programming language for data definition, insertion, and manipulation in relational databases.
An SQL database is basically a term used to classify relational databases that use SQL.
The most popular ones are MySQL, PostgreSQL, Oracle SQL, and T-SQL. Data in SQL databases are represented in rows and columns, making it easier to write intuitive queries

Pros

  • ACID properties (Atomicity, Consistency, Isolation, and Durability)
    SQL databases follow ACID principles in transactions.

    • Atomicity means that the data change in a transaction is interpreted as one. This means that if the transaction fails halfway for some reason, the database state is rolled back.
    • Consistency means that the data from the transaction is still checked against constraints placed on it in the database schema.
    • Isolation means that any changes in a transaction is isolated and would'nt affect any changes in another transaction that's running concurrently. This means that two transactions manipulating the same data resource can't run at the same time but must be queued.
    • Durability means that once the transaction is complete, it's changes will permanently reflect on the database.
  • Easier to query
    Data is normalized in rows and columns in SQL, making SQL databases perfect for complex queries.

  • Larger community
    It’s quite popular, so knowing how to work with SQL databases could improve your chances of landing a job as a data scientist, data analyst, or software engineer.

Cons

  • Consistency for Performance tradeoff
    SQL databases achieve atomicity, consistency, and isolation of data through something called data locks, which basically prevents a transaction from modifying or reading from a resource (row or column) while it’s being used by a different transaction. While this ensures consistency, it takes its toll on the performance of SQL databases compared to NoSQL databases.

  • Difficult to scale
    Horizontally scaling an SQL database can be painful. Techniques such as data sharding/partitioning and master-slave replication can be implemented, but they aren’t as easy as they sound making them difficult and expensive to scale.

What is NoSQL?

NoSQL is a term used to classify databases that don’t store data in a relational manner. While SQL databases only support storing data in rows and columns, we have different kinds of NoSQL databases that we can use, depending on our business needs.

Pros

  • Easier to scale
    Database Sharding in NoSQL is a lot easier than Partitioning in SQL databases. Most NoSQL databases, in fact, do this for you, allowing you to focus on the business logic

  • Faster queries
    NoSQL databases do not follow ACID principles, instead, follow BASE principles. NoSQL databases also, don’t have to worry about joins, making NoSQL database queries faster.

  • More diverse
    Ranging from key-value databases like dynamo DB to document-based databases like MongoDB, to graph databases like neo4j and Tigergraph, NoSQL databases could be a perfect fit for our business needs.
    For example, a road network database could make use of Graph databases, and a social media app could use MongoDB to store posts. A business can decide to use multiple NoSQL databases in its architecture

Cons

  • Performance for Consistency tradeoff
    NoSQL databases don’t implement data locks, while this makes transactions/queries a lot faster than in SQL databases, data is not immediately consistent in the database, making it inappropriate for systems like FinTech applications or MedTech (systems that require data to be immediately consistent after a modification).

  • Smaller user community
    SQL is more popular than NoSQL databases. Also, NoSQL is relatively new in the market, meaning most existing companies already have their database systems implemented in SQL.

When to use SQL or NoSQL

When to use SQL

We use SQL in systems whose data needs can be solved with ACID properties—finance Applications, Invoice Applications, and systems that value data consistency over faster queries.

When to use NoSQL

We use NoSQL databases in systems that require a high volume of data to be processed and stored. This is because NoSQL databases are highly scalable both in storage and in read-write performance. E.g Social media, Blogs, Streaming services.

Will NoSQL replace SQL in the future?

Both databases at this point in history, can’t replace each other, and it’s looking like it’ll stay that way.

The only way NoSQL databases will surface as a replacement for SQL databases is if NoSQL can find a way to ensure that data is immediately consistent and still maintain its query speed.

On the other hand, SQL could potentially replace NoSQL databases in some use cases in the future if they find ways to ensure ACID properties and at the same time not trade its query performance.

Another key point is that most developers and data professionals find querying data with SQL easier and more intuitive than with any other method implemented by NoSQL databases. NoSQL databases like Apache Hive and Tigergraph have solved this problem by providing an SQL interface for querying data stored in its NoSQL databases

The future of DBMS

The future of database systems is the best of both worlds. Combining the ACID properties of SQL with the BASE properties of NoSQL databases

This can be achieved in our present day by implementing a microservices architecture. That way, services that require their database to possess ACID properties could use SQL, and those that require BASE properties could use NoSQL. A good example is Facebook, which uses MySQL, Apache Cassandra, and a lot more NoSQL and SQL databases

Top comments (1)

Collapse
 
franckpachot profile image
Franck Pachot

This converges into Distributed SQL database. For example YugabyteDB has a Cassandra-like and a PostgreSQL-like API. You can have consistent transactions in both. And choose to lower some SQL constraints (enabling single-row transactions, upsert mode) in both.