To understand databases, which are essential to development, you need to know the basic concepts. Today, we will introduce the concept of databases in a way that non-developers can easily understand, and discuss the differences between RDBMS and NoSQL, a non-relational database, and when to use each.
What is a database (DB)? A database is simply a collection of data. There are many different types of databases: Hierarchical, Network, Relational, Object-Oriented, and Object-Relational.
Hierarchical DB is the first DB concept. Because it is organized in the form of a tree, it is difficult to change it once it is initially configured, and it is inefficient to find other data, so it is not used today.
Network DBs emerged to address the problems of hierarchical DBs. Unlike hierarchicals, they are flexible structures that allow data to be linked together, but like hierarchicals, they are rarely used today because they require programmers to understand all the structures before they can write programs.
Relational DBs, also known as RDBs for short, are the majority of DBs in use today. A typical relational database (RDB) is a way of structuring information in tables, rows, and columns. An RDB is organized into the smallest unit called a table, which is made up of one or more columns and rows. All data is stored as rows and columns in a series of tables for efficient processing and data querying.
Relational databases have the ability to join tables to establish relationships or links between information, making it easier to understand and obtain information about the relationships between multiple data points.
Often referred to together with DB, DBMS stands for Database Management System and is the software that manages and operates databases. Databases store a variety of data and need to be shared and accessible to multiple users or applications at the same time, and it is the job of a DBMS to provide this simultaneous access. Common relational DBMSs include MySQL, Oracle, MariaDB, and PostgreSQL.
Relational databases store data in tables organized into fixed rows and columns. Each column stores information about one attribute, and the rows store data that fits the data type of each column.
Relational databases have two key characteristics. The first is that data is stored in tables according to a defined data schema, and the second is that data is distributed across multiple tables through relationships. To put it more simply, you have to define the structure and data types of the tables in advance, and you can only insert data in the form that fits what is defined in the table. This makes it very easy to use if you have entered the data correctly.
NoSQL refers to non-relational databases, which are anything other than SQL, or relational databases. When referring to non-relational databases, we call them NoSQL (or NoSQL databases). In recent years, NoSQL databases have grown in popularity as web applications have become more common and complex.
NoSQL databases are not tabular and store data in a different way than relational tables. They have different types depending on the type of data, with the main types being document, key-value, wide column, and graph. NoSQL does not necessarily have to be schema-less. It offers flexible schemas, and a big advantage is that it can easily scale with large amounts of data and high user load. It also follows the schema when reading data.
For an RDBMS, you store data in tables using the SQL language. You must store data in a prescribed format based on a pre-built schema.
In NoSQL, data is stored in the following ways: key-value, document, wide-column, graph, etc.
A schema is a representation of the logical structure of all or part of a database, indicating how data is stored within the database.
To use an RDBMS, you need a fixed schema. You must decide in advance which columns are organized by the data attributes you want to process before you can process data. You can change the schema later, but you need to define it carefully at the beginning because you may need to modify the entire database or take it offline.
In NoSQL, you have more flexibility than in relational databases to manage the shape of your schema. You can add new columns on the fly as you add rows, and you do not necessarily have to enter data for every column for each individual property.
A query is the act of requesting information from a database. SQL-based relational databases need to request data according to the format of the tables and the relationships between them. Because there is a prescribed way to make requests, you use a structured query language, such as the SQL language.
Because queries in NoSQL are focused on looking up groups of data themselves, you can also request data in an unstructured query language. This is sometimes referred to as UnQL.
SQL-based relational databases scale vertically and use a lot of memory and CPU. They tend to be expensive because they utilize a lot of the power of the hardware on which they are built, and while it is possible to define relationships in a database across multiple servers, it can be very complex and time-consuming.
Databases organized in NoSQL, on the other hand, scale horizontally. The advantage of building additional servers for NoSQL databases is that they can conveniently handle a lot of traffic. NoSQL databases can be hosted on commodity hardware or cloud-based instances, which are cheaper than SQL, making them relatively inexpensive.
ACID is an acronym for Atomicity, Consistency, Isolation, and Durability, which are properties that are required to ensure safety in the process of performing a change of state by a single transaction running on the database.
So far, we have been learning about RDBMS and NoSQL together, but what do you think? If we were to compare RDBMS and NoSQL in one sentence, we would say that RDBMS imposes constraints on data types to ensure consistency and reliability, while NoSQL removes those constraints for speed, flexibility, and scalability.
However, there is no perfect solution when it comes to how to build a database, which is why services are often designed using both relational and non-relational databases. It is important to look at the different use cases for the DB you want to build and choose the right database.