0% found this document useful (0 votes)
10 views5 pages

Neo4j CQL - Introduction

Uploaded by

Ranjithprabhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Neo4j CQL - Introduction

Uploaded by

Ranjithprabhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Page 1 of 5

Neo4j CQL - Introduction


CQL stands for Cypher Query Language. Like Oracle Database has query language SQL,
Neo4j has CQL as query language.

Neo4j CQL

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 commands to perform Database operations.

Neo4j CQL supports many clauses such as WHERE, ORDER BY, etc., to write very
complex queries in an easy manner.

Neo4j CQL supports some functions such as String, Aggregation. In addition to


them, it also supports some Relationship Functions.

Neo4j CQL Clauses


Following are the read clauses of Neo4j Cypher Query Language −

Sr.No Read Clauses Usage

This clause is used to search the data with a specified


1 MATCH
pattern.

This is the same as match, the only difference being it


2 OPTIONAL MATCH
can use nulls in case of missing parts of the pattern.

This clause id is used to add contents to the CQL


3 WHERE
queries.

This clause is used to find the starting points through


4 START
the legacy indexes.

5 LOAD CSV This clause is used to import data from CSV files.
Page 2 of 5

Following are the write clauses of Neo4j Cypher Query Language −

Sr.No Write Clause Usage

This clause is used to create nodes, relationships, and


1 CREATE
properties.

This clause verifies whether the specified pattern exists


2 MERGE
in the graph. If not, it creates the pattern.

This clause is used to update labels on nodes,


3 SET
properties on nodes and relationships.

This clause is used to delete nodes and relationships or


4 DELETE
paths etc. from the graph.

This clause is used to remove properties and elements


5 REMOVE
from nodes and relationships.

6 FOREACH This class is used to update the data within a list.

Using the clauses CREATE and MATCH, you can get a


7 CREATE UNIQUE unique pattern by matching the existing pattern and
creating the missing one.

Importing CSV files


8 Using Load CSV you can import data from .csv files.
with Cypher

Following are the general clauses of Neo4j Cypher Query Language −

Sr.No General Clauses Usage

This clause is used to define what to include in the


1 RETURN
query result set.

This clause is used to arrange the output of a query in


2 ORDER BY order. It is used along with the clauses RETURN or
WITH.

This clause is used to limit the rows in the result to a


3 LIMIT
specific value.

This clause is used to define from which row to start


4 SKIP
including the rows in the output.

5 WITH This clause is used to chain the query parts together.


Page 3 of 5

This clause is used to expand a list into a sequence of


6 UNWIND
rows.

This clause is used to combine the result of multiple


7 UNION
queries.

This clause is used to invoke a procedure deployed in


8 CALL
the database.

Neo4j CQL Functions


Following are the frequently used Neo4j CQL Functions −

Sr.No CQL Functions Usage

1 String They are used to work with String literals.

They are used to perform some aggregation operations


2 Aggregation
on CQL Query results.

They are used to get details of relationships such as


3 Relationship
startnode, endnode, etc.

We will discuss all Neo4j CQL commands, clauses and functions syntax, usage and
examples in-detail in the subsequent chapters.

Explore our latest online courses and learn new skills at your own pace. Enroll and
become a certified expert to boost your career.

Neo4j CQL Data Types


These data types are similar to Java language. They are used to define properties of a
node or a relationship.

Neo4j CQL supports the following data types −

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.


Page 4 of 5

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.

CQL Operators
Following are the list of operators supported by Neo4j Cypher Query language.

Sr.No Type Operators

1 Mathematical +, -, *, /, %, ^

2 Comparison +, <>, <, >, <=, >=

3 Boolean AND, OR, XOR, NOT

4 String +

5 List +, IN, [X], [X…..Y]

6 Regular Expression =-

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
support multiple conditions.

Boolean
Sr.No Description
Operators

It is a Neo4j CQL keyword to support AND operation. It is


1 AND
like SQL AND operator.

It is a Neo4j CQL keyword to support OR operation. It is


2 OR
like SQL AND operator.

It is a Neo4j CQL keyword to support NOT operation. It is


3 NOT
like SQL AND operator.

It is a Neo4j CQL keyword to support XOR operation. It is


4 XOR
like SQL AND operator.
Page 5 of 5

Comparison Operators in Neo4j CQL


Neo4j supports the following Comparison operators to use in Neo4j CQL WHERE clause to
support conditions.

Sr.No Boolean Operators Description

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.

You might also like