Neo4j CQL - Relationship Functions

Neo4j CQL has provided a set of Relationship functions to know the details of a Relationship in getting Start Node,End Node etc. details. 
Here, we are going to discuss some of the important and frequently used functions
Now we will discuss each Neo4j CQL Relationship Functions in detail with examples
It takes a string as an input and convert into upper case letters. All CQL Functions should use "( )" brackets.
STARTNODE (<relationship-label-name>)
NOTE:-
<relationship-label-name> may be a property name of a node or relationship from Neo4j Database.
Example -
This example demonstrates how to use CQL STARTNODE Relationship function to retrieve a Start Node Details of a Relationship.
Before executing STARTNODE() function on Relationship "ACTION_MOVIES", we will check it's details
Step 1 - Type the below command at dollar prompt in Data Browser.
MATCH (video1:YoutubeVideo1)-[movie:ACTION_MOVIES]->(video2:YoutubeVideo2) 
RETURN movie
Step 2 - Click on Execute button and observe the results.
Here, We can observe that STARTNODE of Relationship "ACTION_MOVIES" is "YoutubeVideo1". Let us check this with function.
Step 3 - Type the below command and click on Execute button.
MATCH (a)-[movie:ACTION_MOVIES]->(b) 
RETURN STARTNODE(movie)
It uses STARTNODE() Relationship function to print Start Node of Relationship "ACTION_MOVIES".
Here, We can observe that STARTNODE of Relationship "ACTION_MOVIES" is "YoutubeVideo1".
Example -
This example demonstrates how to use CQL ENDNODE Relationship function to retrieve a End Node Details of a Relationship.
Before executing ENDNODE() function on Relationship "ACTION_MOVIES", we will check it's details
Step 1 - Type the below command at dollar prompt in Data Browser.
MATCH (video1:YoutubeVideo1)-[movie:ACTION_MOVIES]->(video2:YoutubeVideo2) 
RETURN movie
Step 2 - Click on Execute button and observe the results.
Here, We can observe that End Node of Relationship "ACTION_MOVIES" is "YoutubeVideo2". Let us check this with function.
Step 3 - Type the below command and click on Execute button.
MATCH (a)-[movie:ACTION_MOVIES]->(b) 
RETURN ENDNODE(movie)
It uses ENDNODE() Relationship function to print Start Node of Relationship "ACTION_MOVIES".
Here, We can observe that ENDNODE of Relationship "ACTION_MOVIES" is "YoutubeVideo2".
Example -
This example demonstrates how to use CQL ID & TYPE Relationship functions to retrieve Id and Type Details of a Relationship.
Before executing ID & TYPE functions on Relationship "ACTION_MOVIES", we will check it's details
Step 1 - Type the below command at dollar prompt in Data Browser.
MATCH (video1:YoutubeVideo1)-[movie:ACTION_MOVIES]->(video2:YoutubeVideo2) 
RETURN movie
Step 2 - Click on Execute button and observe the results.
Here, We can observe that ID and TYPE of Relationship "ACTION_MOVIES" are "2" and "ACTION_MOVIES". Let us check this with function.
Step 3 - Type the below command and click on Execute button.
MATCH (a)-[movie:ACTION_MOVIES]->(b) 
RETURN ID(movie),TYPE(movie)
It uses ID() and TYPE() Relationship functions to print ID and Type of Relationship "ACTION_MOVIES" details.
Here, We can observe that ID and TYPE of Relationship "ACTION_MOVIES" are "2" and "ACTION_MOVIES".
 Print
 Add Notes
 Bookmark this page