Relational vs NoSQL database

Reading Time: 4 minutes

Relational databases are conventional database management system that use structured query language to define and operate on data. Data is segregated into different tables. And the term relational signifies that the data stored across tables can exhibit relationship among them. RDBMS has a predefined structure of data, which defines what data and what type of data can be stored in a table. Also, it can impose certain constraint over the data to be allowed to store.

To understand, below is a sample schema. Student and Course Tables are associated to each other through course-enrollment relation.

This type of databases, being highly structured and atomic, used to work just fine. Until, traffic & data became so huge to be able to process on single machine. Then, the concept of distributed system came up, which, however, distributed the operational load of the system, but the data access remained from a single node. Couple that with big data, and bam !!! You will have an unusable system after reaching certain scale. If not unusable, with huge amount of data stored in RDBMS, the query will become so slow that it will become a bottleneck for the whole system.

To fix this, the concept of documents based databases came into existence. Which basically suggested to store data into documents instead of tables. The core idea behind this was that while single table with million records will be stored in a big single block of data, the documents can be stored on different systems. Former way is also called as vertical scaling, while the later is known as horizontal scaling. This concept of document based DBMS later became a part of an umbrella term NoSQL database, which, other than documents, can include graph, key-value pair and other data structure based non-relation databases. .

Now that you know, with huge amount of data, traditional RDBMSs fail to cope up with the performance of the system, you might question whether those system became obsolete. The answer is NO. A concept of sharding was introduced to make an RDBMS scale horizontally as well. Besides, NoSQL was never meant, to replace RDBMS. In fact, both the systems have different use-cases and their own advantages.

Now with so many choices, it would be a task in itself to decide on what type of database to choose. To make life easier, Eric Brewer devised an idea know as CAP theorem. Which states that out of consistency, availability and partition tolerance only 2 can be achieved at a time. Below is an image to show case how it fits into different database systems.

Databases developed by different developers / vendors can have different approaches towards specific aspect of performances. For simplicity’s sake, I will be taking MySQL and MongoDB into consideration for generic comparison between between an RDBMS and NoSQL.

Leave a Reply