Data Development July 14,  2022

NoSQL databases: Turning down SQL for good or an alternative?

Sofía Acher   •  Communication Specialist   •  Linkedin
AB
Ariel Baquero   •  SQL Developer   •  Linkedin

NoSQL databases store information in a way that satisfies the data being stored, instead of storing it in columns and rows as in relational databases. NoSQL means “not only SQL”, as in not necessarily SQL, it is important to clarify that it does not mean no SQL. NoSQL databases are made to be flexible (as they adapt to the information being stored), scalable and capable of quickly responding to data management needs of modern businesses. The most popular kinds of NoSQL are document databases, key-value stores, wide-column databases, and graph databases. The first are built to store information such as JSON documents, that consist of fields that are name-value pair objects, and can be used to store XML documents, that are strictly text files, as well (Couchbase N/Y, IBM, N/Y). Key-value stores put associated data together in collections with records identified with unique keys for facile retrieval. They have just enough structure to mirror the value of relational databases, and still maintain the benefits of NoSQL. Wide-column databases use the tabular structure of relational databases while allowing a wide variety in how data is named and formatted in each row, even in the same table. As well as key-value stores, wide-column databases have some basic structure but still preserve a lot of adaptability. Lastly, graph databases use graph formats to define the relationships between stored data points. They are useful to identify patterns in unstructured and semi-structured data (Couchbase, N/Y).

NoSQL is different from SQL because while SQL databases are relational, NoSQL databases are non-relational or distributed (Dawson, N/Y). The difference between relational and nonrelational databases lies in the way they store information. SQL databases are table-based while NoSQL databases are, as previously mentioned, document-based, graph databases, wide-column stores, or key-value pairs. The structured query language is actually where SQL (Structured Query Language) obtains its name. In NoSQL databases, the focus for queries is on the collection of documents. In addition to this, in SQL databases the data is stored in tables consisting of rows, whereas data in NoSQL has no standard format definition to adhere to. That is to say, NoSQL has dynamic schema while SQL databases consist of predefined schema. Moreover, SQL databases are horizontally scalable while SQL databases are vertically scalable. In other words, to scale NoSQL, one should increase the DB servers in the cluster for load balancing. To scale SQL, one should increase the horsepower of the CPU, SSD, RAM and other hardware on the server, which means NoSQL is the best choice if scalability is a major consideration, especially when taking advantage of cloud hosting. As well as this, on the one hand, SQL allows for interaction as it is a declarative query language. Once one establishes what one wants to display, the database extracts the results after assembling an algorithm internally. On the other hand, NoSQL requires one to know what one wants as well as to state exactly how to produce the answer (MongoDB, N/D).

How can you know when to use SQL and when to use NoSQL? Data structure should be previously defined before choosing one database system over another. There are cases in which information consistency will be 100% necessary, in which the type of data that is part of the same collection should not differ. In this case, the best choice is SQL. There are other scenarios in which there is not a lot of time to implement necessary application validations to provide the app with a necessary level of consistency. As in SQL databases, an important part of this job is made by the database manager, in NoSQL it is the entire responsibility of the development team. In contexts in which data structure is constantly changing and is highly variable, the best option is a NoSQL system. These cases are more and more common nowadays, specially with the growth of Big Data and Internet of Things, in which the vast amount of data and the wide variety of devices makes the data we manage very variable and almost impossibly uniform. Another factor to consider when deciding to use SQL or NoSQL is scalability. In SQL systems, horizontal scalability, which is the ability to increase the capability of an app’s service, is hard to implement by adding different physical nodes. This is because of the safety they offer in data consistency, dividing data related to other tables in different physical nodes is costly. In NoSQL systems, this does not carry any difficulty. Every register has complex objects inside their attributes; it is not tied to other data structures through a defined relationship in an established scheme (Codehoven, N/Y).

According to Joaquín Kachinovsky, our CTO, NoSQL is still a rare choice over SQL. “In our experience, NoSQL has proven valuable in the management of unstructured data for log files and configuration files for some systems. This has made it easy to store and retrieve different kinds of data regardless of what it is. However, my personal feeling is that SQL tends to be a better fit for most scenarios. My recommendation is to stay open to the possibility of using NoSQL, but do not rush to it as if it were the new silver bullet for your projects. The differences between both are clear and there are upsides and downsides to each one. Also, many projects benefit from keeping some data in SQL and others in NoSQL format. There is no need to stick to one of them through the whole project.” 

References:

Dawson, J. (2017, 9 septiembre). Understanding the Difference between NoSQL and SQL. Compare the Cloud. Recuperado 30 de diciembre de 2021, de https://www.comparethecloud.net/articles/understanding-the-difference-between-nosql-and-sql/

JSON documents. (s. f.-a). IBM. Recuperado 30 de diciembre de 2021, de https://www.ibm.com/docs/en/db2/11.5?topic=concepts-json-documents

JSON documents. (s. f.-b). IBM. Recuperado 30 de diciembre de 2021, de https://www.ibm.com/docs/en/db2/11.5?topic=concepts-json-documents

L. (2021, 21 septiembre). Base de datos: SQL y NoSQL. Ilimit. Recuperado 31 de diciembre de 2021, de https://www.ilimit.com/blog/base-de-datos-sql-nosql/

MongoDB. (s. f.). Explicación sobre las bases de datos NoSQL. Recuperado 31 de diciembre de 2021, de https://www.mongodb.com/es/nosql-explained

NoSQL Databases – What They Are and Why You Need One. (s. f.). Couchbase. Recuperado 30 de diciembre de 2021, de https://www.couchbase.com/resources/why-nosql

O. (2020, 19 noviembre). NoSQL vs SQL: Qué es NoSQL y cuándo utilizarlo. CodeHoven. Recuperado 31 de diciembre de 2021, de https://www.codehoven.com/nosql-vs-sql/Vergara, A. (2016, 26 julio). SQL vs NoSQL ¿Cuál debo usar? Tech blog for developers | Facilcloud. Recuperado 31 de diciembre de 2021, de https://www.facilcloud.com/noticias/sql-vs-nosql-which-one-should-i-use/

Sofía Acher Communication Specialist   •  Linkedin
AB
Ariel Baquero SQL Developer   •  Linkedin