DEV Community

Cover image for SQL vs. NoSQL
Patrick
Patrick

Posted on

SQL vs. NoSQL

In my previous article about what CRUD is, I also discussed that a part of any application is a database.

Today, a database is almost necessary for every application, because it allows us to store different data.

Databases can be relational or non-relational, they can be accessed via the Internet and the Internet, or they can be local on a local device.

Today, I will walk between relational and non-relational databases.

Relational Databases (SQL)

Relational databases are the most used databases. Data in these databases are stored in tables and rows.

The relational database is like Excel worksheets.

Relational databases have better readable data than non-relational databases because they have very structured data.

For creating queries in those databases is used an existing language called SQL is.

Advantages of relational database:

  • Great choice for structured data
  • Great choice for demanding queries

The biggest drawback of a non-relational database is the inability to dynamically change the schema. After all, if we want to add a new attribute to a relational database, this will affect the entire database.

At the same time, compared to non-relational databases, they need more time to execute and search for data.

Some relational databases:

Server

Non-relational databases (NoSQL)

Non-relational databases contain unstructured, structured or structured data, usually in a key-value pair.

The big advantage of those databases is the option of being very flexible. This allows you to quickly add new attributes which do not impact the full database.

The advantage of such a database is that we can store a lot of data in one table.

The non-relational database is faster than the relational sub-database.

The disadvantage of such a database is that each has its own method of making queries for managing data in the database.

Some non-relational databases:

Conclusion

I can figure out that relational databases are the best option in an application that had structured data and we want to have them portable and an option for use in different infrastructures. But, a lot of companies still use relational databases.

But non-relational databases get the most out when we start creating a project and want to have a lot of flexibility. Also, the non-relation database is great if we store a huge amount of data.


If you like reading what I write, you can donate me a cup of coffee or start following me on Twitter(@Patik123_).

Discussion (9)

Collapse
darkain profile image
Vincent Milum Jr

There are many MANY more types of databases too, such as graph databases, spacial databases, columnar databases, and more.

But what's best of all? MariaDB has support for ALL of these at once. Just because a database server is traditionally one style doesn't mean it is exclusively limited to JUST that one style.

Collapse
patik123 profile image
Patrick Author

True, there are a huge number of databases, but most web applications use only relational and non-relational databases.

Yes MariaDB has the features of both databases together, which is great.

Collapse
andrewbaisden profile image
Andrew Baisden

You forgot to mention HarperDB which can no SQL and NoSQL 😁

Collapse
patik123 profile image
Patrick Author

MariaDB also has data storage functions in JSON format 😁.

Collapse
margo_hdb profile image
Margo McCabe

Great discussion! This article might help to expand upon some of the points you make as well: Database Architectures & Use Cases - Explained

Collapse
patik123 profile image
Patrick Author

Thank you 😁. And your post is awesomeπŸŽ‰.

Collapse
natescode profile image
Nate

With an ORM flexibility isn't really an issue as migrations handle things i.e. during prototyping phase.

NoSQL or document dBs scale horizontally while traditional SQL mostly scales vertically.

Collapse
bobbyiliev profile image
Bobby Iliev

Great post!

For anyone interested in learning more about SQL I could suggest this free eBook here:

GitHub logo bobbyiliev / introduction-to-sql

Free Introduction to SQL eBook

πŸ’‘ Introduction to SQL

This is an open-source introduction to SQL guide that will help you to learn the basics of SQL and start using relational databases for your SysOps, DevOps, and Dev projects. No matter if you are a DevOps/SysOps engineer, developer, or just a Linux enthusiast, you will most likely have to use SQL at some point in your career.

The guide is suitable for anyone working as a developer, system administrator, or a DevOps engineer and wants to learn the basics of SQL.

πŸš€ Download

To download a copy of the ebook use one of the following links:

πŸ“˜ Chapters

🌟 Sponsors

Thanks to these fantastic companies that made this book possible!

πŸ“Š Materialize

…

Collapse
patik123 profile image
Patrick Author

Thank you😊.