Cypher vs. SQL: When do you need a graph database?
A Talk by Prashanth Rao (AI Engineer, Kùzu Inc.)
About this Talk
Developers who work with data most likely have experience in some dialect of SQL, and are familiar with the relational data model. However, there are certain scenarios in which a graph data model can be beneficial.
In this masterclass, we will introduce the property graph data model and go over the key features of Cypher, a declarative query language for graphs. The goal is to demonstrate certain classes of queries whose logic is easier to express (and likely to run faster) when using a graph database that implements Cypher. Developers coming from relational databases and SQL will find Cypher to be a refreshingly familiar graph analogue to SQL.
To demonstrate these concepts, we transform an existing tabular dataset into a graph and ingest it into Kùzu, an open source, embedded graph database management system that implements Cypher. We will perform a comparison between SQL and Cypher queries that answer the same questions on the same data, highlighting both the similarities and the differences between them. As the class progresses, we will also demonstrate some methods to use LLMs to generate Cypher from user questions asked in natural language.
By the end of the masterclass, attendees will come away having a greater appreciation for data modelling and query workloads that could benefit from graphs, how to answer questions using Cypher, as well as the skills to construct and query their own knowledge graphs from a variety of sources that can power modern search/retrieval systems or RAG applications.
Key Topics
- Property graph data model and the Cypher query language
- Graph queries and traversals using Cypher
- Flexible joins, recursive queries and pattern-matching queries in Cypher
- Transforming tabular data into graphs
- ETL and data transformation workflows for graphs
- Using LLMs to query graphs
Target Audience
- Data Scientists
- Data Engineers
- Machine Learning Engineers
- Data Analysts
- Managers of the above
Goals
Get hands-on experience using Cypher and interacting with a graph database to answer questions about your data.
Session outline:
- Introduction to the property graph data model
- Characteristics of Cypher
- Examples of how some queries are hard to answer in SQL, but easy and intuitive in Cypher
- Recursive querying and the notion of paths
- Flexible join sequences
- Query patterns in the data
- Visualising graphs to gain insights
- Practical demo: Running Cypher queries in Kùzu
Format
This class is hands-on.
The beginning of the class will start in a lecture format, but will quickly move to hands-on coding exercises. A combination of command line tools, Python scripts and Docker containers will be used during the session.
We will be working with Jupyter notebooks or Python scripts run from the command line (participants’ choice) with standard Python packages installed via pip. To visualise the graph, we use Docker to launch a visualisation tool called Kùzu Explorer, so it’s useful to have an installation of Docker on your machine.
Level
Beginner - Intermediate
Prerequisite Knowledge
Basic knowledge of Python and the command line (and an even more basic knowledge of Docker) is beneficial.