Choosing the right database
When starting a new project, there’s often a time to start thinking about storing data. There are many different databases you can choose from, but they more or less boil down to two types, SQL and NoSQL, and sometimes making the choice between the two can be tough, so I’ll bring up some of the key differences of these types of databases in an attempt to help those making this decision.
SQL
First I’ll talk about SQL databases and their properties. One thing to note, when using SQL, you must already know what information you are planning on receiving. This is because SQL uses schemas, which are the form of the data, and must be defined before any data can be added. If you are not entirely sure of the data you will be receiving, it is most likely a better idea to start with NoSQL. SQL databases are useful for relational data, that is data that has some sort of connection to other pieces of data. Think about a message system, each user will have their sent messages, their chat rooms, and their friends, all of which are related to them. With these relations, it makes queries regarding these (I.E friends of friends) simple. The two last points about SQL databases are very important. First, they have only one source of truth for any given piece of information. That means that there is only one spot in the database where a single piece of information can appear. This is important in keeping the data in your database consistent and error-free.
NoSQL
While there are many reasons to choose a SQL database, NoSQL offers up some unique advantages over SQL databases. Most notably, in a NoSQL database you do not need to know the structure of the data, and anything you ask to be put into the database will be stored. This is important to startups who may not know all the information they need from the start. Due to not having the create schemas, NoSQL databases are also generally quicker to set up. It’s also possible to store relational data into NoSQL databases, some databases that allow this will run on a SQL database behind the scenes.
If you are looking for a quick and easy database to get started with, or if you do not know all the information you may need to store yet start out with a NoSQL database, otherwise if you are willing to put the extra work into a SQL database and plan on scaling your product, SQL is the way to go.