Neo4j Building Blocks - Neo4j

How to build blocks in Neo4j?

Neo4j Graph Database has below building blocks

  • Nodes
  • Properties
  • Relationships
  • Labels
  • Data Browser

Node

Node is a fundamental unit of a Graph. It consists of properties with key-value pairs as shown in below image.

node

Here, Node Name = "Employee" and it contains a set of properties as key-value pairs.

Properties

Property is a key-value pair for describing Graph Nodes and Relationships.

Where Key is a String and Value may be represented using any Neo4j Data types.

Relationships

Relationships are another major building block of a Graph Database. It connects two nodes as depicted in below figure.

relationship

Here, Emp and Dept are two different nodes. "WORKS_FOR" is a relationship between Emp and Dept nodes.

As it denotes, the arrow mark from Emp to Dept, this relationship describes

Each relationship consists of one start node and one end node.

Here, "Emp" is a start node, and "Dept" is an end node.

As this relationship arrow mark represents a relationship from "Emp" node to "Dept" node, this relationship is known as an "Incoming Relationship" to "Dept" Node and "Outgoing Relationship" to "Emp" node.

Similar to nodes, relationships also consist of properties as key-value pairs.

properties

Here, "WORKS_FOR" relationship holds one property as key-value pair.

It represents an Id of this relationship.

Labels

Label associates a common name to a set of nodes or relationships. A node or relationship consists of one or more labels. New labels can be created for existing nodes or relationships and existing labels can be removed from the existing nodes or relationships.

In the above diagram, there are two nodes.

Left side node has a Label: "Emp" and the right-side node has a Label: "Dept".

Relationship between those two nodes also has a Label: "WORKS_FOR".

Note − Neo4j stores data in Properties of Nodes or Relationships.

Neo4j Data Browser

After installing Neo4j, you can access Neo4j Data Browser using below URL

data_browser

Neo4j Data Browser is used for executing CQL commands and view the output.

Here, you have to execute all CQL commands at dollar prompt: "$"

Type commands after the dollar symbol and click on "Execute" button to run your commands.

It interacts with Neo4j Database Server, retrieves and displays the results just below the dollar prompt.

You can make use of "VI View" button to see the results in diagrams format. Above diagram displays results in "UI View" format.

You can make use of "Grid View" button to see the results in Grid View. Below diagram displays the same results in "Grid View" format.

grid_view

While using "Grid View" to view the Query results, you can export them into a file in two different formats.

CSV

Click "Export CSV" button to export the results in csv file format.

csv

JSON

Click on "Export JSON" button to export the results in JSON file format.

json

However, if you use "UI View" to see the Query results, you can export them into a file in only one format: JSON

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Neo4j Topics