hands-on lab

Query a Neo4j Graph Database With Cypher

Difficulty: Intermediate
Duration: Up to 40 minutes
Students: 127
Rating: 4.2/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.

Description

Neo4j is becoming a standard for graph databases. With its simplicity and potential, you can start building reliable and useful databases. A key feature of Neo4j is the language used both as DDL and DML: Cypher. Cypher is a powerful language that uses clauses similar to SQL. Although, Neo4j is a NoSQL DBMS so Cypher doesn't work on structured data, as SQL does. When you need to query a graph database, you need to define the graph pattern first. A graph pattern is a graphical and logical way to identify the graph resources (nodes and edges) you want to query. You can think of a graph pattern as a subgraph of the whole graph you will query. Cypher uses an ASCII-Art syntax to represent the graph pattern. That's a very good approach because you can graphically think about what you need to query to create the Cypher query. In Cypher, nodes are referred with () and edges with []. One of the simplest graph patterns is the following: (:label_1)-[:type_1]->(:label2) which represents a relationship between two nodes (the first labelled with label_1 and the second labelled with label_2) through an arch whose type is type_1.

In this lab, you will use Cypher to query a Neo4j graph database.

Learning Objectives

Upon completion of this beginner level lab, you will be able to:

  • Understand how a graph pattern is structured
  • Perform graph queries using Cypher

Intended Audience

  • Data engineers who want to start using Neo4j as a graph database solution
  • Developers who want to start performing graph queries using Cypher

Prerequisites

To get the most out of this lab, you should have basic knowledge of the concepts of graph databases and Neo4j. To achieve this, we suggest taking the following labs:

Updates

July 7th, 2022 - Fixed environment error

Environment before

Environment after

Covered topics

Lab steps

Connecting to the Neo4j Web Application
Querying the Graph Data