What the Database?
If you’re a fan of the Internet, chances are you’ve site or application that stores important information in a database behind the scenes. On your own coding journey, learning about the different types of ways data can be stored can help prepare your application for the future. Two of the most popular methods of database storage are SQL and NoSQL. Neither is necessarily better, since each has its own benefits and drawbacks, but rather, what’s important is figuring out which database is a better idea for that project you’re currently starting.

SQL — If It Ain’t Broke, Don’t Fix It
In the 1970’s, IBM developed SQL — structure-based query language. The most defining characteristic of this language is that it is structured. Data is (erm… are) stored in tables that look a lot like Excel spreadsheets. This way of data storage is great if all elements inside the database have the same properties. For example, if you are creating a blog, you will have to store the title, author, and the content.
SQL is what’s known as a relational database, which is defined as a database structured to recognize relations among stored items of information. Because of this, tables can be easily joined, since there are no anomalies. These sorts of databases support ACID transactions.
The basis of a relational database is this — if you are creating a site or application where you know the data you will be using will not change and can fit into equal tables, the more structured language (rightly called SQL) may be for you.
Some great SQL-databases include MySQL, SQLite, and PostgreSQL
NoSQL — Dynamic Schemas
For around three decades, the ability to store data in SQL databases was sufficient. Then game-changers like Facebook and Amazon started using a whole lot of data. Something new had to be done. This is where NoSQL began to take off.

Whereas SQL prides itself as being structured, NoSQL databases are dynamically structured, so defining things beforehand is not necessary. The popularity of JSON also sparked additional interest in NoSQL, making tools like MongoDB the preferred choice of databasing due to developers’ familiarity with working with the JavaScript Object Notation format (meaning, many object-oriented programming languages like Java or PHP).
NoSQL databases are document-based. Instead of storing data in tables, the data is stored in collections made from individual documents. Most likely, this is done in a JSON document, but it is also possible to store the data in graphs or key/value pairs.
NoSQL may be the preferred method of storage if you are unsure what kind of data will be coming in. To use the blog example from above, if you decided to use a NoSQL database from the start, you could add more dimensions to your database that you had not considered early on with ease (perhaps adding categories or tags).
Examples of NoSQL-databases are Couchbase, Cassandra, Redis, and MongoDB.
Choose What Works for You
The best method of getting to know which database will be best for you is to experiment with both. MongoDB (the M in MEAN Stack) has been the most popular as of recently, but understanding its shortcomings may allow you to more greatly appreciate the power of an old school SQL database.
Happy coding!
