Better Programming

Advice for programmers.

Follow publication

You're unable to read via this Friend Link since it's expired. Learn more

Member-only story

What is a Graph Database Anyway?

Dmytro Khmelenko
Better Programming
Published in
4 min readJun 9, 2021
Photo by Clint Adair on Unsplash

Graph databases are not a new concept. Graph theory was actively developed in the 1960s and since then the first attempts for building storage for graph structures have already appeared. The general idea is to persist the graph as a data structure and operate with it through the queries. It is like a mixture of graphs and databases, taking the best parts of both of them.

The main driver for graph databases was the expansion of social networks and the improvements of recommendation engines. Social networks want to know the person’s connections better in order to suggest new friends, while recommendation engines mine the person’s interests to find the ideal next proposal.

Let’s explore how graph databases work, their main principles, and their advantages.

Idea

From the graph theory, we know that every graph consists of two essential components: vertex and relation. A vertex defines the actual data, a relation describes how different vertices connect to each other. The simplest and most popular example would be a social graph:

An example of the social graph

We can see that every node in the graph represents a person. Each person has properties for name and age. Describing people with these properties looks similar to the entry in the SQL database — but this is the only similarity.

What makes a graph database different is the connections between the vertices. Every node can have multiple relations (or edges). In more complex systems, the edges can have their own properties. For instance, weights define how strong the connection between the nodes is. In our example, we have different types of connections between the vertices. All connections with their properties are persisted as well.

In relational databases like PostgreSQL and MySQL, the relations between the entries are defined through one-to-many and many-to-many relations. Those relations are not persisted explicitly. We have to run multiple queries and combine the results through the JOIN command. This makes read operations…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Dmytro Khmelenko
Dmytro Khmelenko

Written by Dmytro Khmelenko

Software Engineering | Startups | Education| Technical Leadership | Learn how to boost your career from “Unlock the Code” http://amzn.to/3j5Nm27

No responses yet

Write a response