The Beginner’s Guide to the Neo4j Graph Platform
By: Ng Wai Foong
Tags: Neo4j, Data Science, Database, Programming, Big Data

1. Setup

Java

Before you continue with the installation, you need to make sure that either OpenJDK 11 or Oracle Java 11 is installed in your machine. You can easily check it by running the following command in the terminal.

java --version

You should see the following output

Image by Author

I am using the OpenJDK 11 build made by AdoptOpenJDK, which is open-sourced and available for free.

Neo4j

At the time of this writing, the latest community version is 4.1.1. Head over to the official download page and download the neo4j main file based on your operating system. Once you click on the download link, the download will start and you will be redirected to a new page with the installation steps.

In this tutorial, the steps provided are based on the Windows platform. Kindly refer to the official installation steps if you are using other operating systems. Extract the files at the directory of your choice. You should see the following files and folders.

Image by Author

There are two ways to run Neo4j:

As console application

As service

Console application

The simplest method is to run it as a console application via the following command. NEO4J_HOME refers to the base directory where you extracted the file.

<NEO4J_HOME>\bin

eo4j console

The following output will be displayed at your terminal:

Image by Author

In console mode, the process is tied to the terminal. It needs to stay open in the foreground.

Service

On the other hand, service runs the process in the background. It will continue to run even if the terminal is closed. To install it as a service, run the following command:

<NEO4J_HOME>\bin

eo4j install-service

After that, you can start it normally via the following command:

neo4j start

The following list contains some of the useful commands based on Windows PowerShell module:

stop — Stop the process

— Stop the process restart — Restart the process

— Restart the process status — Check the status of the process

— Check the status of the process uninstall-service — Remove neo4j as service

Neo4j console

The next step is to access it in your browser. Open up a browser and go to the following URL.

It will redirect you to:

with the following user interface:

Image by Author

If you are accessing it for the first time, simply connect to the database via the following username and password:

username — neo4j

— neo4j password — neo4j

It will prompt you to change the password. Make sure you remember the new password, as subsequent logins will use the new password. Once you have logged in, you should see the following interface:

Image by Author

The part highlighted in red represents the input area where you can type in the query language to be executed.

You can find three buttons on the right side as follows:

star — Update the query as your favourite

— Update the query as your favourite eraser — Clear the input area

— Clear the input area play — Execute the query. You can use the shortcut key Ctrl+Enter to trigger the execution.

Each time you ran a command, results will be shown and recorded down. The part highlighted in blue represent the built-in command that will be run each time you refreshed the browser.

Sample datasets

Neo4j comes with two sample datasets for you. Run the following command if you intend to follow the built-in tutorial.

The first dataset demonstrates the common query patterns on actors and movies in cross-referenced pop culture. Run the following in the input area to start the tutorial.

:play movie graph

In addition, the second dataset covers on loading data from external csv files. You will learn to transition from RDBMS schema to graph structure using some classical datasets. You can start the tutorial via the following command: