Databases

Significance

Modern applications work on data. Data is the new oil. Data needs to be persisted apart from the application server. Databases are used for persisting data over time. This means that even if we close our application or our server crashes, our data will be stored safely in a database somewhere. Data is important and, thus, databases form one of the most important components of any application. Databases give us a way to organize and store our data in cheap stores. It is difficult to create a smart application without a database and still be taken seriously.

Database options

We have two big categories of databases to choose from. These categories are:

1. Relational Databases

2. NoSQL Databases

Now, we will discuss both of these options in detail.

Relational databases

Relational databases were first invented in the 1970s. We have probably heard about some relational databases in the past. PostgreSQL, MySQL, and Oracle are some examples of good relational databases. In relational databases, we have tables and relations between them as the basic entity. Data is stored as rows within tables. And these tables are connected by foreign key and primary key attributes. Relational databases follow SQL language for CRUD operations. Relational databases are still the best choice for many applications.

Advantages of relational database

Relational databases are a good choice for applications whose data is naturally structured. These applications are easily modeled as relational schema. Banking applications are a good example of this.

Relational databases provide consistency during write operations. Hence, if multiple applications are querying our data, it makes sense to use relational databases. They will make sure that all of the applications receive the same data.

Also, SQL, the language used in relational databases, is fairly well known. Thus, there won’t be a big learning curve for the developers using them.

Limitations of relational databases?

Times have changed since relational databases were first introduced. Most of the data on the internet is unstructured and morphs continuously. For example, data about the music you like on YouTube will be hard to structure in relational databases. New features of the data will become important as the platform changes over time.

The mismatch between the application data and relational schema needs is called Impedance mismatch. Relational databases are a good solution for some applications. However, they are not the most elegant solution for modern applications.

Due to the strict consistency feature, relational databases do not scale well horizontally. When we make a copy of the data across machines, we will update the data on all machines in case of write operations. This slows down write operations on large data sets.

Also, with the advent of Agile methodologies, it has become a common practice to change the schema of our databases frequently. This is very cumbersome on relational databases.

NoSQL databases

NoSQL databases offer solutions to the limitations of SQL databases. They give us fast access and horizontal scaling with schema-less design. NoSQL is an umbrella term for all modern databases which are not relational in nature. The full form of NoSQL is “Not Only SQL.” This term originated from a meetup with the same name. This meet-up was created to discuss these new databases. NoSQL databases, like MongoDB and DynamoDB, power most of the social media websites, e-retail websites, and other modern applications. Therefore, NoSQL databases are here to stay.

Types of NoSQL databases

These are the types of NoSQL databases:

- Key-Value

- Document-Based

- Graph-Based

- Column Based

Advantages of NoSQL databases

NoSQL databases provide speed at high scales. They do this by scaling horizontally across multiple machines. They also provide the flexibility of expressing our data in a model that is closer to our domain. The learning curve involved in a NoSQL database is relatively short, so they are a good choice for a small team. There are many managed options available for NoSQL databases, which makes it headache-free to use these databases.

Get hands-on with 1200+ tech skills courses.