Getting Started with Graph Database Queries, with Cheat Sheet!

Graph databases are gaining momentum every year. They will never completely replace relational databases, and they aren’t trying to. But they will start to enter the spaces where data lakes and data warehouses are struggling.

Graph databases are gaining momentum every year. They will never completely replace relational databases, and they aren’t trying to. But they will start to enter the spaces where data lakes and data warehouses are struggling. A graph database is faster and more intuitive to analyze networks of events, resources, and people:

  • Financial transactions involving complex patterns, and occasional fraud
  • Healthcare interactions between patients, medical staff, facilities, and equipment
  • Supply chain webs of customers, vendors, contractors, and products
  • Manufacturing bill of materials with recipes for input materials

Those types of networked relationships are difficult to model and visualize in a relational or dimensional data model. The graph database provides a structure to mimic the real-world networks in business.

Getting Started with Graph Database Queries, with Cheat Sheet! As you get started with graph databases and the query languages, it is important to prepare for a shift in your mental model. First off, there is not yet a widely accepted standard query language like SQL. As you can see in the attachment, there is a group of competing languages and a committee struggling to get everyone to agree on a single GQL standard.

For our purposes today, we will use the Cypher query language, which is developed and promoted by the top database vendor, Neo4j. In graph queries, we lose some syntax from SQL and gain other syntax. SELECT has been replaced by MATCH. FROM and JOIN have been discarded. But the WHERE and ORDER BY commands are used in the same way. Aggregate functions like SUM and AVG are all there, but the GROUP BY has been discarded. Most importantly, though, we gain the ability to query patterns in the graph using the node relationships.

In the attached Cheat Sheet, you will see a list of the most commonly used query approaches. Following is the graph model that will be used in the attached cheat sheet: Getting Started with Graph Database Queries, with Cheat Sheet!

Let's Work Together

Book a free 25-minute product consultancy with our experts