A Comparison of Label Property Graph and the RDF

Atakan Güney
5 min readNov 27, 2019

--

In this blog, I will briefly explain what the Labeled Property Graph is and what are the differences and similarities with RDF(Resource Description Framework) and I will try to show how to map those two in a well-known graph database: Neo4j.

Introduction

First of all, if you are not familiar with RDF, you can read my previous humble blog post.

Secondly, if you are not familiar with the graph, you can look at the following two great blog posts from Selen Parlar:

The Label Property Graph

So, the label property graph is one of a few data representation approaches, that is utilized in graph databases. That is, the data is organized as nodes, relationships, and properties. A node is an entity that can have zero or more properties. Properties are key-value pairs. Finally, relationships link two nodes in a directed way. Moreover, relations may also have zero or more properties. Let’s see an example from a sample dataset in Neo4j.

Movie Data Set Example of Neo4j

Let’s see a node’s and a relationship’s properties in this data set.

On the left-bottom you see the properties of the node “Jack Nicholson”
Now, you see the properties of a relationship

Differences between RDF and LPG

As you may think, the graph represented by RDF triples can be converted into a property graph. But why do we need this conversion? There are certain advantages of the property graph over the RDF graph. First, the RDF triples are easy statements to produce but when the query takes place it may give a headache. Secondly, since relationships in the property graphs can have properties, this may simplify the modeling process. Thirdly, relationships that are repeated are counted as unique, e.g. a person like another person only one in the RDF representation. Of course, these problems can be worked around by the modeling techniques but overall, it seems to have the property graph more intuitive. These advantages of the property graphs arise a question: Why do we use the RDF triples? Because they are the so easy way to transfer and save relationships and there are already a certain amount of the RDF data sources. In addition, the property graphs may be a burden on the applications. For further comparison of these two different ways to represent graphs, I suggest watching the following talk.

Example of both

Now, let’s dive into a little bit and see how data can be represented in both the RDF and LPG. Do you remember our funny RDF data 😃

And in an RDF store, you would get the following triple list.

This is a local RDF store server called RDF4j you can try it by following the instructions here.

Because I showed how to query RDF data, I skip this time and do the same query on the property graph.

MATCH (n:Person) RETURN n.name
Query results in Neo4j
Corresponding SPARQL results in rdf4j

Mapping RDF to Property Graph vice versa

As stated above, the RDF is the most used relation representation framework in the Web and there are billions of sources that produce RDF data. To be linked to these huge linked data, somehow we should consume and produce RDF representation of our graph database. Special thanks to NSMNTX, we can easily import-export RDF data sets and construct RDF endpoints on Neo4j. The NSMNTX is a plugin for Neo4j, which enables the use of RDF in the database. For detailed information, you can set up the plugin and follow their nice documentation.

Before jumping into the mapping functionality of NSMNTX, let’s start creating a sample property graph with Cypher.

CREATE(p1: Person{name: "Atakan", age: 25})
CREATE(p2: Person{name: "Riza"})
CREATE(p3: Person{name: "Selen"}
CREATE(p4: Person{name: "Suzan"})
CREATE (p1)-[:knows]->(p2)
CREATE (p3)-[:knows]->(p4)
CREATE (p4)-[:knows]->(p3)

This Cypher code snippet should create following graph

Let’s integrate RDF data into our graph. We first need to define schemas.

call semantics.mapping.addSchema("http://schema.org/", "Person", "Person")
call semantics.mapping.addSchema("http://schema.org/Person#", "knows", "knows")
call semantics.mapping.addSchema("http://schema.org/Person#", "friendOf", "colleagues")

After calling these you should be able to see following schema list

And the general graph will change as follows

So, it adds mappings into the graph.

Conclusion

The graph databases are so helpful to store data that have complex relationships among them. In addition, these databases provide lots of effective graph algorithms to analyze the data. Neo4j is one of the most used graph databases and its integration with RDF data would lead to more deep analysis and it may be worth to connect your storage with linked data through Neo4j. For more interesting tools, please stay tuned 🚀

--

--