Nodes represent entities in the graph. Relationships define connections between nodes.
Nodes: (node_name:Label {property1: value1, property2: value2})
Relationships: -[relationship_name:RELATIONSHIP_TYPE {property1: value1}]->
A comprehensive cheat sheet for Neo4j's Cypher query language, covering syntax, common operations, and best practices for graph database interactions.
Nodes represent entities in the graph. Relationships define connections between nodes. Nodes: |
Example of Node creation:
Example of Relationship creation:
|
|
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. |
|
Example:
|
Matching Nodes: |
Examples:
|
|
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). |
Directed: |
Example:
|
Creating a Node: |
Example:
|
|
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. |
|
Example:
|
Cypher supports aggregation functions like |
Example:
|
|
Creates a new list based on an existing list, filtering and transforming elements. |
Example: |
|
Neo4j has built-in procedures and functions, and you can also create your own. |
Example:
|