SQL or NoSQL, That is the Question

If you’ve built any app that stores data you’ve had to make a choice on how you will manage that data. You have a common choice of a SQL or a NoSQL database but which should you choose? What are some of the differences and advantages of these? Let’s get into it.

What is a SQL Database?

A database is an organized collection of data, generally stored and accessed electronically from a computer system. SQL is a language which allows users to create, modify and query the collection of data. SQL databases are considered relational meaning that they rely on the relational model. These relationships are clearly defined and stored in related tables. Some common examples of these are MySQL Database, Postgres, Oracle, Ms SQL Server and Sybase.

These databases employ predefined schemas to determine the structure before you can work with them. This can create problems down the road if changes need to be made.

Whats a NoSQL Database?

A NoSQL database in contrast to SQL one is that it is non-relational. This type of database emerged in the late 2000s as data storage costs decreased while the amount of data increased. All of this data came in different forms as structured, semistructured and polymorphic. Due to this, defining a schema beforehand was not really an option as it can be restrictive down the road. The noSQL database allows developers to store vast amounts of data as they see fit without being locked into a predefined format. This type of database is optimal for large datastores which need to be queried quickly.

SQL

Pros

  • Flexible queries: Enables support for diverse workloads. Abstracts data over underlying implementations.
  • Reduced data storage footprint: Due to normalization and other optimization opportunities, a reduced footprint maximizes database performance and resource usage.
  • Strong and well-understood data integrity semantics: Atomicity, consistency, isolation and durability, or ACID, are database properties that guarantee valid transactions.

Cons

  • Rigid data models: Requires careful up-front design to ensure adequate performance and resistance to evolution. SQL has a predefined schema, so changing it often includes downtime.
  • Limited horizontal scalability: It is either completely unsupported, supported in an ad-hoc way or only supported on relatively immature technologies.
  • Single point of failure: Non-distributed engines are mitigated by replication and failover techniques.

NoSQL

Pros

  • Scalable and highly available: Many NoSQL databases are designed to support seamless, online horizontal scalability without significant single points of failure.
  • Flexible data models: Most non-relational systems do not require developers to make up-front commitments to data models. Existing schemas are dynamic, so they can often be changed “on the fly.”
  • Dynamic schema for unstructured data: Documents can be created without a defined structure first, which enables each to have its own unique structure. Syntax varies per database and fields can be added as you build the document.
  • High performance: A limited database functionality range enables high performance amongst many NoSQL databases.

Cons

  • Vague interpretations of ACID constraints: Despite the widespread belief that it supports NoSQL systems, ACID interpretations can be too broad to make clear determinations about database semantics.
  • Distributed systems have distributed systems problems: Though not specific to NoSQL systems, encountering such problems is common amongst NoSQL developers and may require SME troubleshooting.
  • Lack of flexibility in access patterns: Without the abstraction found in relational databases, the on-disk representation of data leaks into the application’s queries and leaves no room for NoSQL engines to optimize queries.

Now that you have a better understanding of SQL and noSQL databases you can make better design decisions in your next project. The two types provide some significant strengths and differences which need to be taken into account early on. The type of database you choose to work with will depend on the type of data and how you wish to manipulate it.

Sources Used: https://www.xplenty.com/blog/the-sql-vs-nosql-difference/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Google Summer Of Code 2021 with CloudCV

Collection of 5 Most Useful Scripts in Python (Part 5)

From MVP to MVI —Model-View-Intent Journey Part I

Player Missiles part 2!

Committing to Memory — An Absolute Beginner’s Introduction to Git

How to open the Microsoft Excel from C#.net

How to use Images in Markdown

Consider using Options instead of undefined.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bart Minczuk

Bart Minczuk

More from Medium

Well test you’re right here already and signing up takes minutes you’ll by no means while you’ll…

Easy way to solve Increment Decrement Operator Problems

Tachyon 8 — a strategy to speed up your problem-solving process

i will truly never forget #rtvf298 💗