What are Databases? And what's NoSQL vs SQL?
Databases form the backbone of most modern applications. For example, LinkedIn uses databases to store this post and everything that it contains: the header image, text, comments, etc... Think of any other application you've used in the last few days, and chances are that every single one of them runs at least one or more databases to store, retrieve, and update data. Simply put, databases store a variety of data such as usernames, email addresses, encrypted passwords, and virtually any other type of data that you can imagine.
Otherwise, without a database, the application wouldn't know what to display!
We also have a video version of this post if you'd rather watch than read:
When it comes to databases, though, there are different options. The two types of database management systems that I'll mention in this post are:
- Non-relational databases, or NoSQL
- Relational databases, which use SQL (Structured Query Language which is a language that makes it possible to manage the requested data easily)
Because NoSQL and SQL database management systems (DBMSs) have different pros and cons, in some cases, it can make sense to run both types for the same application.
Shutterfly, the popular photo publishing site, uses a non-relational database to help manage their image data. But, they also use a relational database to help organize their customers’ billing info.
NoSQL Databases
So when would you want to use a NoSQL database? As we talked about, Shutterfly uses NoSQL to store image metadata. This is a good use case because the image data doesn’t require a lot of structure and can be stored as a key/value pair using JSON.
JSON example:
Examples of NoSQL database management systems that are available are:
- MongoDB
- Couchbase
- Amazon DynamoDB
NoSQL is also generally regarded as being much faster and more scalable because it has a lot less overhead. So if you know for a fact that your data won't require much structure and that you will need a lot of scalability or performance, NoSQL might be the best way to go.
SQL Databases
NoSQL databases are fantastic for certain use cases, but then other instances will require that you use a relational database. Going back to the Shutterfly example, they might have 3 separate tables in their relational database:
- For the customer’s info
- For billing information
- For the images that a user has uploaded
In one SQL command, you’re able to pull information across all of those tables which would not be as easily accomplished with a non-relational database.
SELECT * FROM Customer C JOIN Billing B ON C.Id = B.Id JOIN Images ION I.Id = B.Id
Some examples of relational database management systems are:
- PostgreSQL
- MSSQL
- MySQL
There are a lot more advanced differences between the two types of databases, and so if you would like to learn more about databases, take a look at our new course Database Essentials. It will give you a much more detailed look at the differences using Hands-On Labs to teach you how to install these various DBMSs on real servers.