Should We Use NoSQL Instead Of SQL? If Yes, When?

Mert Savaş
Berkut Teknoloji
Published in
4 min readDec 21, 2021

In this article, I tried to share my knowledge about NoSQL and SQL databases. I hope, you will enjoy it!

What is SQL?

SQL is Structured Query Language, which is a language for managing and designing data in a relational database. It is commonly used to operate databases for CRUD operations, such as create, read, update and delete. Relational Database Management Systems like MySQL, Oracle, MS Access, PostgreSQL and SQL Server use SQL as their standard database language. Moreover, some different dialects are used to describe these management systems, such as

  • MS SQL -> T-SQL
  • Oracle -> PL/SQL

What is NoSQL?

NoSQL databases (also known as “Not only SQL”) are non-relational and non-tabular databases. NoSQL databases store the data differently than SQL databases. There are many implementation types of NoSQL databases. The most common examples are key-value, wide-column, document, and graph. I’m going to mention about the most popular ones.

Key-Value Store (Redis, Riak, Oracle NoSQL, Apache Cassandra)

Key-Value databases are the most popular and simplest amongst NoSQL databases. We can store the data as JSON, integer, string, or array with a key which is given as a reference. In this type, generally map or dictionary data structures are used.

Benefits of using this implementation can be described as having rapid storage of data and having integrated caching feature, which allows users to store/retrieve data as quickly as possible. The major advantages for the key-value store are speed and simplicity. The disadvantage is being difficult to perform advanced queries aside from basic CRUD operations. When the stored data increases, maintenance of unique keys becomes more difficult.

Column-Based Store (Apache Hbase, MariaDB, Cassandra)

Column-based databases store data in columns rather than rows. Relational databases store data in rows and data properties as column headers. Row-based and column-based databases use SQL as their query language. Column-based databases perform the queries faster than a row-based databases. But write operations may take longer to complete. The overall benefits of a column-based database include data compression, high performance with aggregate functions. However, vast number of insert and delete operations might have a negative impact on performance, especially if the table has plenty of columns.

Document-Based Store (MongoDB, CosmosDB, DynamoDB)

A document-based store database designed to store and query data as JSON or like PDF, XML and Word documents. Document-based databases help developers to store and query data in a database by using the same document model they use in their project that makes easier for development. However, they are also limited to advanced queries and does not allow any joins. A modification that includes two collections will require you to run two separate queries. Furthermore, one of the major disadvantages is security lacks.

What are the differences between SQL and NoSQL?

When do we use NoSQL or SQL?

SQL database is more advantageous when

  • You need to perform flexible queries
  • You need to store structured data
  • Your access patterns aren’t defined
  • You need to enforce field constraints
  • You need to store relational data

NoSQL database is more advantageous when

  • Performance is crucial to your project
  • You need low latency
  • You need to store unstructured data
  • Your access patterns are defined
  • You don’t need to store relational data

Thanks for reading! Bye

References

--

--