CQL stands for Cypher Query Language. Like Oracle Database has query language SQL, Neo4j has CQL as query language.
- Is a query language for Neo4j Graph Database.
- Is a declarative pattern-matching language.
- Follows SQL like syntax.
- Syntax is very simple and in human readable format.
Like Oracle SQL
- Neo4j CQL has instructions to perform Database operations.
- Neo4j CQL helps many clauses which include WHERE, ORDER BY, and so on., to write down very complicated queries in an smooth manner.
- Neo4j CQL helps some capabilities such as String, Aggregation. In addition to them, it additionally supports some Relationship Functions.
Neo4j CQL Clauses
Following are the read clauses of Neo4j Cypher Query Language −
|1||MATCH||This clause is used to search the data with a specified pattern.|
|2||OPTIONAL MATCH||This is the same as match, the only difference being it can use nulls in case of missing parts of the pattern.|
|3||WHERE||This clause id is used to add contents to the CQL queries.|
|4||START||This clause is used to find the starting points through the legacy indexes.|
|5||LOAD CSV||This clause is used to import data from CSV files.|
Following are the write clauses of Neo4j Cypher Query Language −
|1||CREATE||This clause is used to create nodes, relationships, and properties.|
|2||MERGE||This clause verifies whether the specified pattern exists in the graph. If not, it creates the pattern.|
|3||SET||This clause is used to update labels on nodes, properties on nodes and relationships.|
|4||DELETE||This clause is used to delete nodes and relationships or paths etc. from the graph.|
|5||REMOVE||This clause is used to remove properties and elements from nodes and relationships.|
|6||FOREACH||This class is used to update the data within a list.|
|7||CREATE UNIQUE||Using the clauses CREATE and MATCH, you can get a unique pattern by matching the existing pattern and creating the missing one.|
|8||Importing CSV files with Cypher||Using Load CSV you can i|
Following are the overall clauses of Neo4j Cypher Query Language −
|1||RETURN||This clause is used to define what to include in the query result set.|
|2||ORDER BY||This clause is used to arrange the output of a query in order. It is used along with the clauses RETURN or WITH.|
|3||LIMIT||This clause is used to limit the rows in the result to a specific value.|
|4||SKIP||This clause is used to define from which row to start including the rows in the output.|
|5||WITH||This clause is used to chain the query parts together.|
|6||UNWIND||This clause is used to expand a list into a sequence of rows.|
|7||UNION||This clause is used to combine the result of multiple queries.|
|8||CALL||This clause is used to invoke a procedure deployed in the database.|
Neo4j CQL Functions
Following are the often used Neo4j CQL Functions −
|1||String||They are used to work with String literals.|
|2||Aggregation||They are used to perform some aggregation operations on CQL Query results.|
|3||Relationship||They are used to get details of relationships such as startnode, endnode, etc.|
We will talk all Neo4j CQL instructions, clauses and capabilities syntax, usage and examples in-element inside the subsequent chapters.
Neo4j CQL Data Types
These facts types are much like Java language. They are used to outline residences of a node or a courting.
Neo4j CQL helps the following records sorts −
|Sr.No||CQL Data Type||Usage|
|1||Boolean||It is used to represent Boolean literals: true, false.|
|2||byte||It is used to represent 8-bit integers.|
|3||short||It is used to represent 16-bit integers.|
|4||int||It is used to represent 32-bit integers.|
|5||long||It is used to represent 64-bit integers.|
|6||float||It is used to represent 32-bit floating-point numbers.|
|7||double||It is used to represent 64-bit floating-point numbers.|
|8||char||It is used to represent 16-bit characters.|
|9||String||It is used to represent Strings.|
Following are the list of operators supported through Neo4j Cypher Query language.
|1||Mathematical||+, -, *, /, %, ^|
|2||Comparison||+, <>, <, >, <=, >=|
|3||Boolean||AND, OR, XOR, NOT|
|5||List||+, IN, [X], [X…..Y]|
|7||String matching||STARTS WITH, ENDS WITH, CONSTRAINTS|
Boolean Operators in Neo4j CQL
Neo4j supports the following Boolean operators to use in Neo4j CQL WHERE clause to guide a couple of situations.
|1||AND||It is a Neo4j CQL keyword to support AND operation. It is like SQL AND operator.|
|2||OR||It is a Neo4j CQL keyword to support OR operation. It is like SQL AND operator.|
|3||NOT||It is a Neo4j CQL keyword to support NOT operation. It is like SQL AND operator.|
|4||XOR||It is a Neo4j CQL keyword to support XOR operation. It is like SQL AND operator.|
Comparison Operators in Neo4j CQL
Neo4j helps the following Comparison operators to use in Neo4j CQL WHERE clause to aid situations.
|1||=||It is a Neo4j CQL "Equal To" operator.|
|2||< >||It is a Neo4j CQL "Not Equal To" operator.|
|3||<||It is a Neo4j CQL "Less Than" operator.|
|4||>||It is a Neo4j CQL "Greater Than" operator.|
|5||<=||It is a Neo4j CQL "Less Than Or Equal To" operator.|
|6||> =||It is a Neo4j CQL "Greater Than Or Equal To" operator.|