Graph Databases and Neo4j

Posted by on in Blogs

Recently I have come across "Graph Databases" free book from O'Reilly. This book is about Neo4j graph database and is really inspiring! 

Back in Delphi 10.0 "Seattle" the new FireDAC database access driver for MongoDB was introduced. That was probably the first time I have looked closely at NoSQL databases. Why should I care? Why more and more organisations are moving away from traditional SQL-92 databases toward faster, less expensive, and lighter alternatives? NoSQL became the whole movement. Maybe you just want to store some unstructured data and do not really need the power of "Structure Query Language"?

MongoDB is a very powerful data store for everything JSON. It was great to see that as a side effect to introducing MongoDB support in Delphi "Seattle", there was a lot of general new JSON functionality introduced into Delphi RTL libraries. Here is a link to a whitepaper about JSON support in Delphi 10.

The product behind O'Reilly's "Graph Databases" book is Neo4j. What traditional "relational" databases are missing is proper support for the concept of "relations". In SQL databases there are tables, but queries that relate different columns from different tables together are a kind of after-thought. Graph databases are different. Here a "node" or data is equally important as "edge" or connection between nodes. A really complex types of queries that would be too expensive for traditional SQL are main stream in graph databases. There is also a special query language for graph databases called "Cypher". Here is a sample from one tutorial site that illustrates differences between Cypher and SQL.

Let's find all customers with last name "Brown". Here is this query in Cypher:


The same query expressed in SQL:


There are certain complex queries that could be prohibitively expensive to execute in SQL, while in graph databases work very fast. Think about very complex WHERE clause.

As usual Wikipedia explains what "Cypher Query Language" is quite well. It is interesting that pieces of Cypher look very similar to their underlying where nodes are connected through relations that can themselves be tagged.

I would love to see Neo4j support in Delphi one day!

Gold User, Rank: 9, Points: 364
Crazy about Delphi Programming!


Check out more tips and tricks in this development video: