Catalog / Neo4j Cypher Cheatsheet
Neo4j Cypher Cheatsheet
A comprehensive cheat sheet for Neo4j's Cypher query language, covering syntax, common operations, and best practices for graph database interactions.
Cypher Basics
Nodes and Relationships
Nodes represent entities in the graph. Relationships define connections between nodes. Nodes: |
Example of Node creation:
Example of Relationship creation:
|
Basic Syntax
|
Used to find nodes and relationships in the graph based on a pattern. |
|
Used to create new nodes and relationships in the graph. |
|
Used to update properties of nodes and relationships. |
|
Used to delete nodes and relationships. |
|
Used to remove properties or labels from nodes and relationships. |
|
Specifies what data should be returned by the query. |
Common Clauses
|
Example:
|
Pattern Matching
Basic Pattern Matching
Matching Nodes: |
Examples:
|
Variable Length Relationships
|
Match relationships of exactly length |
|
Match relationships of length between |
|
Match relationships of minimum length |
|
Match relationships of maximum length |
|
Match relationships of any length (including zero). |
Directional Relationships
Directed: |
Example:
|
Data Manipulation
Creating Nodes and Relationships
Creating a Node: |
Example:
|
Updating Data
|
Updates or creates a property on a node or relationship. |
|
Replaces all properties on a node or relationship. |
|
Removes a specific property from a node or relationship. |
|
Removes a label from a node. |
Deleting Data
|
Example:
|
Advanced Cypher
Aggregations
Cypher supports aggregation functions like |
Example:
|
List Comprehension
|
Creates a new list based on an existing list, filtering and transforming elements. |
Example: |
|
Procedures and Functions
Neo4j has built-in procedures and functions, and you can also create your own. |
Example:
|