Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Introduction to Graph Databases

Friday, July 14th, 2017 by Servage

database-queryYou may have worked with relational databases such as MySQL before, but what about graph databases? Graph databases are data storages for the semantic web, and their structure differs from a typical relational database. Let’s have a closer look at how a database like this works and what it can be used for.

Data Storage Model

A relational database stores data in key-value pairs in rows of a table where a column (key) has a value. Graph databases are not tied to data structures such as columns or tables. Instead, a graph database uses nodes, properties and edges. Although these terms may be new to you, fortunately they map surprisingly well to the relational database model.

Let’s start with nodes. They are similar to rows in relational databases. You could say that one node equals one object, such as a person. Graph databases are simple to understand because it’s easy to construct real-world sentences from the contents of a database. If we do this, nodes can be considered the nouns of a sentence.

Next up is properties, which you can think of as columns in relational databases. Properties are attached to nodes to describe them. Properties are the adjectives of a sentence, such as the age of a person or the length of a movie.

Lastly we have edges, also called relationships. They are indeed the equivalent of relationships in relational databases, and they can be used to connect nodes together. For example, a person node can be connected to a car node using an edge. In plain English this would mean that the person owns a car.

Query Languages

Like relational databases, graph databases also need a query language to add, read and manipulate data inside a database. However, unlike with relational databases, there is no de-facto standard when it comes to query languages for graph databases. SQL is not an option because it is for relational databases, so therefore multiple alternatives exist. SPARQL and Cypher are among the most common ones.

Advantages of a Graph Database

Some big websites like eBay and Walmart have made the decision to go with a graph database instead of a relational one, so surely there must be some benefits in doing so.

First of all, graph databases are fast. Relational databases often have to scan through the whole table to find the necessary piece of information while graph databases only inspect the directly connected nodes. When tables grow large, this can be a significant performance benefit for a graph database.

Another advantage is that with graph databases, you can easily add or remove properties from a node, and similar nodes can have a different amount of properties. In relational databases, you might have to resort to table migrations in order to do this.

However there are also downsides with graph databases and they are not meant to replace relational databases. Both databases serve their own purposes, and before starting a new project, you should review the requirements of the project to see which one works better for you.

Introduction to Graph Databases, 5.0 out of 5 based on 2 ratings
Categories: Tips & Tricks


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.