Open In App

Neo4j Query Cypher Language

Last Updated : 16 Mar, 2023
Like Article

The Neo4j has its own query language that called Cypher Language. It is similar to SQL, remember one thing Neo4j does not work with tables, row or columns it deals with nodes. It is more satisfied to see the data in a graph format rather than in a table format. 

Example: The Neo4j Cypher statement compare to SQL 

MATCH (G:Company { name:"GeeksforGeeks" })

This Cypher statement will return the “Company” node where the “name” property is GeeksforGeeks. Here the “G” works like a variable to holds the data that your Cypher query demands after that it will return. It will be more clear if you know the SQL. Below same query is written in SQL. 

SELECT * FROM Company WHERE name = "GeeksforGeeks";

The neo4j is made for NoSQL database but it is very effective on relational database too, it does not use the SQL language. 

ASCII-Art Syntax: The Neo4j used ASCII-Art to create pattern. 

  • In the Neo4j the nodes are represented by “( )”.
  • The relationship is represented by ” -> “.
  • What kind of relationship is between the nodes are represented by ” [ ] ” like [:GeeksforGeeks]

So above description is helpful to decode the ASCII-Art Syntax given, (X)-[:GeeksforGeeks]->(Y). Here the X and Y are the nodes X to Y relation kind is “GeeksforGeeks”. 

Defining Data: Below points will help you to grasp the concept of Cypher language. 

  • Neo4j deals with nodes and the nodes contains labels that could be “Person”, “Employee”, “Employer” anything that can define the type of value field.
  • Neo4j also have properties like “name”, “employee_id”, “phone_number”, basically that will gives us information about the nodes.
  • Neo4j’s relationship also can contain the properties but this is not mandatory.
  • In Neo4j the relationship is like the kind of situation like X works for GeeksforGeeks here the X and the “GeeksforGeeks” is the node and the relation is works for, in Cypher language it will be like.

Note: Here the Company is the node’s label, name is the property of the node 

MATCH (G:Company { name:"GeeksforGeeks" })

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads