Neo4j CQL - NULL



Neo4j CQL treats null value as missing value or undefined value to properties of a Node or Relationship.

When we create a Node with existing Node label name without specifying its properties values, then it creates a new Node with NULL property values.

Let us examine this with an example.

Example

This example demonstrates how CREATE command sets NULL values to Undefined properties. How to retrieve all rows of a Node without NULL Rows.

Step 1 - Open Neo4j Data Browser

Neo4j CQL Tutorial

Step 2 - Type the below command at dollar prompt in Data Browser.

MATCH (e:Employee) 
RETURN e.id,e.name,e.sal,e.deptno
Neo4j CQL Tutorial

Step 3 - Click on Execute button and observe the results.

Neo4j CQL Tutorial

Here observe all Employee nodes does NOT contain NULL property values.

Step 4 - Type the below Command and click on Execute button

CREATE (e:Employee)
Neo4j CQL Tutorial

If we observe the above success message, it has not created any property to Employee node.

Step 5 - Type the below Command and click on Execute button

MATCH (e:Employee) 
RETURN e.id,e.name,e.sal,e.deptno)
Neo4j CQL Tutorial

If we observe these results, then the previous CREATE Command has inserted an Employee node by setting all its properties values to NULL

Step 6 - Type the below Command and click on Execute button

MATCH (e:Employee) 
WHERE e.id IS NOT NULL
RETURN e.id,e.name,e.sal,e.deptno
Neo4j CQL Tutorial

If we observe these results, it does not return NULL values row because we have provided a WHERE clause to filter that row i.e. Id property should not contain NULL value.

WHERE  IS NOT NULL

Here we are using IS NOT operator to filter NULL row.

Step 7 - Type the below Command and click on Execute button

MATCH (e:Employee) 
WHERE e.id IS NULL
RETURN e.id,e.name,e.sal,e.deptno
Neo4j CQL Tutorial

If we observe these results, it returns only NULL values row because we have provided a WHERE clause to check ID value is NULL.

WHERE  IS NULL

Here we are using IS operator to return only NULL row.

Advertisements