SQL or NoSQL?

database

When it comes to choosing a database for our project, one of the biggest decisions we have to make is to decide whether we’re gonna use a relational (SQL) or non-relational (NoSQL) data structure. While both are effective options, there are key differences between them that we have to look closely at so we could make a better decision.

SQL – Relational database

SQL databases are table based databases, which means that SQL databases represent data in the form of tables, where each data entry is represented as a row in the table. SQL databases use structured query language (SQL) for defining and manipulating data. SQL requires that we use predefined schemas to define the structure of our data before we start working with them. This can require significant upfront preparation.

The biggest advantages of using a relational database are:

  • ACID (Atomicity, Consistency, Isolation, Durability)
  • Our data remains unchanging and structured
  • SQL databases are a good fit for the complex intensive environment
  • SQL tools have better support

SQL database also has some disadvantages:

  • We need to pay much attention to the data structure before we add data itself
  • Usually, relational databases scale vertically, which means adding more power(CPU, RAM) to an existing machine which can be quite expensive

NoSQL – Non-relational database

NoSQL databases store data in a format other than relational tables. These databases are document-based, key-value pairs, graph databases or wide-column stores. NoSQL databases do not use standard schema definitions.

Advantages of NoSQL over SQL:

  • Create documents without upfront defined data structures
  • NoSQL is easier to manage and has a higher level of flexibility
  • Horizontal scaling – we can scale by adding more machines into our resources pool
  • Because they are so new, NoSQL databases don’t have legacy code

Some of the drawbacks of using NoSQl:

  • Most NoSQL databases do not perform ACID transactions
  • Lack of standardization
  • Less community support

Conclusion

In conclusion, we learned that both SQL and NoSQL have their own advantages and drawbacks. In the end, the choice of the database will always depend on our project/business requirement as well as on the volume and variety of the data we will work with.