SQL Vs NoSQL in 2018
Databases and SQL are probably not the first thing that comes to your mind when you think about learning a new technology. You may think about learning Python or R for data analysis. Or maybe Swift for developing apps. Over the last couple of years, you may have also heard of the new NoSQL technologies that are becoming more popular. But in a world of big data and real-time analytics, databases and SQL are more important than ever. If you are designing a web app, 99% of the time it will be built on a database and the number one thing which will determine the speed of your app, or the accuracy of your data, is how well your database is structured.
What is a database and what makes it relational?
A database is an ordered collection of information (data) that allow us to store and access data. There are many different types of database models each with different ways to store and access data, but by far the most popular model is the relational database model.
In a relational database, data is stored in tables (also known as relations) with a unique key identifying each row of data. These unique keys can be used to link tables together (in relationships). It is this structure that allows us to identify and access data in relation to another piece of data in the database. It is these relationships which make relational databases so powerful and offer data consistency within the database. SQL (which stands for Structured Query Language) is the language used to interact with relational databases; it’s used to create tables within a database, as well as inserting, modifying and deleting data and extracting data from a database.
The most well-known databases are Oracle, SQL Server and Sybase. All these databases are relational databases and the most widely used of them all is MySQL. In fact, a recent survey of stack overflow members found that over 50% of them have used MySQL in their professional lives.
Other Database Models
Relational databases were invented by Edgar Codd in 1970 while he was working for IBM and they have been the most popular database model ever since. There are other types of database models such as flat file databases and document databases. Over the last few years, a document models referred to as NoSQL has become increasingly popular.
NoSQL stands for Not Only SQL and describes a wide variety of different database technologies. The most popular of these technologies in the document database model, or document-oriented database. In the document database model, data is not stored in tables; the document is the most basic unit of data and is similar to a row of data in a relational database table. Documents are ordered sets of key-value pairs. Each document in the database is not required to have the same data structure. Examples of a document you could store in the database would be a JSON blob, XML file or even CSV file. The database also contains collections which are groupings of documents. Collections are like tables in a relational database.
The advantages of document databases are that they are able to handle large volumes of structured or semi-structured data, easier to scale and can offer high availability. Some good examples of using document database include: event logging (storing user logins for example), E-Commerce applications (storing data from users shopping carts) and real-time analytics.
SQL Vs NoSQL
While NoSQL databases do offer some advantages over SQL (relational) databases, there are also a lot of disadvantages. Data consistency and data integrity are major problems for NoSQL databases. There are very few techniques for ensuring that data remains consistent across the database. Another disadvantage is a lack of standardisation. Where as SQL is used to interact with all relational databases (MySQL, Oracle, Sybase, etc.), there is no such standard language for NoSQL databases and there is a wide variety between different NoSQL databases. Security is also an issue – authentication and encryption are very weak for NoSQL databases. It is these advantages on data consistency and security which have made relational databases the most popular form of database for the last 40 years.
Conclusion
In this information driven age of big data, choosing the correct database for your application is more important than ever. While relational databases have been around for over 40 years and you may be tempted by the ‘newer’ NoSQL database technology, there are some things you need to consider. The data consistency and data integrity offered by relational databases means they are a must if your application is dealing with financial information and transactions. You want your database to be secure and the security features offered by relational databases (or rather not offered by NoSQL databases) give it a clear advantage over the competition. You may also want to be able to query your data using a standard language and this is where SQL comes in handy.
All this means that it is vital that you know how to use relational databases and SQL. There is a very good reason why relational databases have been number one for so long; 90% of the time they are the best choice, and that isn’t going to change anytime soon.
Interested in learning more about SQL. Take a look at my Sql for Beginners – learn SQL using MySQL and Database Design course on Udemy. It is live and has been very well received by students and will get you up to speed and skilled in SQL and MySQL.
1 Comment
How did the performance characteristics of SQL and NoSQL databases compare in 2018 for different types of applications?