Relational DB & Graph DB: What are the unique characteristics and advantages?

RDB & GDB: WHat are the unique characteristics & Advantages?

Introduction to Relational DB & Graph DB

The relational DB and graph DB are the most popular databases known for their own respective strengths and unique characteristics. They are no more a subject of competition because one is not superior to the other.

The use of relational DB and graph DB depends on the characteristics and purposes of the data. The table structure of a relational DB is suitable for storing records of general information or uncomplicated relationships, which is why relational DBs are generally applied in accounting or bank cash transactions.

Graph DB, on the other hand, is most effective for relationship-oriented analysis of complex data. This helps data experts spot unexpected connection patterns. The best-known use cases for graph DBs include social media analytics, fraud detection, and real-time recommendation engines. Mapping relationships between data also has the advantage of being easily conveyed via separate visualization tools.

The two databases can offer different pros and cons in how they structure their relationships. NoSQL, a category in which the graph DB belongs, is an abbreviation of “Not Only SQL”, which means it does not replace the SQL of the relational DB but embraces it. The synergy effect of the graph DB optimized for data utilization and analysis along with the existing system brings new insights and reinforces decision-making for business processes.

It is necessary to understand the differences between the relational DB and graph DB before applying either one of them in a project. As mentioned above, the use of each DB depends on the purpose of use.

Relational Database

A relational DB stores data in tables. A table is defined by having columns and rows. Each row is identified by a unique key that links to a row in another table, and each table contains a primary key that identifies information found within the table. Since they can be divided into the same exact schema, the relational DB is able to manage data accurately.

Additionally, the relational DB is divided into a logical structure of tables, a structure of physical storage. This allows data experts to make changes to the physical data structure without affecting the logical structure.

The relational DB requires additional tables containing information from existing tables to model the relationship with other tables. As shown in the image below, you can see a network of tables linked to analyze the products the customer has purchased.

Join operation of RDB showing customer purchased products
Join operation of RDB showing customer-purchased products

Graph Database

While the relational DB can only manage structured data, the NoSQL databases are able to analyze semi-structured and unstructured data as well. These data are generally schema-less, hence the reason why relational DB struggles to manage them.

2013–2022 Database Trend
2013–2022 Database Trend <Source: DB Engines.com>

According to the trend chart from DB-Engines.com, the graph database is the most popular database in the NoSQL market. It is showing overwhelming growth in the market, which signifies the recognition of its future value. Gartner, one of the global market research institutes, predicts that by 2025, 80% of companies around the world will use the graph DB.

The basic components of a graph DB are as follows:

Node: the main object of the graph. Similar to ‘row’ in RDB

Edge: expresses the relationship between objects. Similar to the ‘foreign key’ of RDB

Label: a property that groups similar nodes together

Properties: keys/values stored within a node or edge (relationship)

Social Network in Graph
Social Network in graph

In the social network graph shown above, everyone is represented by a single node labeled as ‘Person’. This node contains properties such as name, gender, location, and email. Relationships (edge) between people in that network are specified as ‘FRIENDS_WITH’ with a time period of their friendship included as a property as well. A person node is also connected with a location node with an edge named, ‘LIVES_IN’.

The image above is a simple example, but it shows the general idea of how a relationship of data is expressed in the graph DB. Adding properties to some nodes can be done easily in a graph DB, so it gives data experts more flexibility when it comes to data modeling. The graph DB is able to extract values and retrieve meaningful insights for the analysts.

When to use RDB or GDB?

The following details will help you decide when to choose which database over the other. To maintain the existing system or to further advance the system depends entirely on your choice.

Choice #1: Fast analysis or Log management

The graph DB is suitable for predictive analytics and fraud detection because it easily finds and identifies hidden patterns that are difficult to find with the naked eye. Since it is generally optimized for data inquiry and analysis, it is an excellent choice if these are important traits to consider for the project.

However, if there is no need for data analysis and the purpose of the project is to simply record data in logs, the relational DB may be a better choice.

Choice #2: Depth of relationship

The graph DB is worth considering when there are numerous connections or patterns within the stored data and when meaningful insights need to be returned. It efficiently finds hidden patterns, providing additional factors to aid in decision-making. Converting structured, semi-structured, and unstructured data into a graph DB can broaden the perspective on data understanding.

The relational DB is more suitable than the graph DB if the project is more transaction-oriented. Sometimes it is better to simply store and manage data rather than trying to understand the relationship between data.

Choice #3: Consistency of data model

Finally, the graph DB is recommended when the data model needs to be changed frequently. The graph DB is schema-less, so its flexibility in adding properties is well known. Additional attributes can be added in order to understand the depth of analysis or when the attribute of certain data is not strictly defined (eg. unstructured data such as video or photos).

On the other hand, table data of the relational DB boasts consistency, which becomes its advantage. When storing personal information such as name, date of birth, location, etc., the relational DB may be more efficient due to not having to change new fields or data often.

‘RGDB’, a multi-model that can use both RDB & GDB

At present, finding hidden insights from a vast amount of data is becoming a trend as it could mean increasing corporate competitiveness. As such, the number of cases taking advantage of the efficiency of both the relational and graph databases is increasing.

For example, let’s say a bank has decided to build an AI management system using data from a relational DB that has been used for monitoring voice phishing. This bank has millions of accounts with transaction history and the detailed transactions between accounts and accident reports must all be recorded in a table format. The storage and management of big data can be maintained with the existing management system just fine, but among the data, some parts may require pattern tracking or deep analysis (eg. transaction info between accounts) for further insights. In that case, the said data can be transferred to the graph DB for analysis and the analyst will be able to find, for example, fraudulent activities like abnormal transactions.

In fact, many of the current big data platforms implemented with the graph DB also maintain relational DB for data management. Each DB working together may be able to bring out a synergy that complements each other’s strengths and weaknesses.

The purpose is the key

As there are always two sides to everything, the graph DB, despite being the latest database technology, is not a perfect solution to all problems. The same can be said of relational DBs that many companies have been using for a long time. Depending on the need of the company, either one of them or both may be required.

The main reason for choosing the graph DB is to analyze data relationships. As for relational DB, it is to accurately aggregate numerous data. If you want to apply both for different purposes and increase efficiency at the same time, you may want to consider a multi-model database with a mix of the two. For example, accurate management of existing data can be done with a relational DB and data analysis with a graph DB. This is one of the ways to gain new insights while maintaining the existing data management paradigm.

Before deciding which database to choose, it would be wise to consider what characteristics your data have or what you want to achieve from the data. Seeking a tip from an expert consultant regarding the decision may also be a good choice. In the end, the choice is yours to decide.

--

--