Hadi Fadlallah
Visualized graph

Getting started with the Neo4j graph database

February 5, 2021 by

In this article, we will talk briefly about graph databases and what Neo4j is. Then we will give a step-by-step guide on how to install and get started with Neo4j on Windows operating system.

This article is the second in the NoSQL databases series, where we will explain different NoSQL database technologies, and how to integrate them with SQL Server databases.

What is a graph database?

It is a NoSQL database used to store network graphs. They are used to model relationships between objects, not only data. While traditional SQL is based on logic and set theory, graph databases are based on graph theory.

In this type of NoSQL database, data is represented as node (entities) and edges (relations) where each node or edge can have one or many properties (attributes) assigned. Since it is a NoSQL database, a graph database doesn’t require a pre-defined model to store data. As an example, two different persons may have different properties:

  1. Employee (name: Mike Rose, Age: 25)
  2. Employee (name: Tim Moshin, DOB: 1980-01-01)

This database is more efficient than relational databases in performing analyzing networks, especially when handling large datasets where JOINS operations are expensive. Graphs are used for artificial intelligence, fraud detection, social network analysis, and other promising domains.

What is Neo4j?

Neo4j is the most popular graph database. It is very performant and guarantees high scalability, making it used by many leading companies such as Microsoft, HP, IBM, Adobe, CISCO, and eBay. Neo4j is an open-source database project that was first released in February 2010. The latest stable version is 4.2.1, which was released last month (2020-11-17).

Cypher is the language used to query and administer Neo4j graphs.

Neo4j Installation on Windows

This section is a step-by-step guide to download and install the latest version of Neo4j Desktop.

To download the latest version of Neo4j desktop, you should open your browser and navigate to the Neo4j download page.

Neo4j database download page

Figure 1 – Neo4j download page

Click on the download button to start downloading the Neo4j desktop installation file. After clicking the download button, you are asked to fill in some information before getting started.

Neo4j database Download required information

Figure 2 – Download required information

After filling in the information and clicking on the “Download Desktop” button, the file download process starts. And you are redirected to a page that includes the activation key you will need later.

Neo4j desktop Activation key

Figure 3 – Activation key

After the download is complete, open the installation file. Neo4j installation is straightforward; you must only specify if you need to install it on the current user or all user accounts.

Choosing installation option

Figure 4 – Choosing Installation option

The next step is to select the installation path.

Selecting the installation path

Figure 5 – Selecting the installation path

Installation progress

Figure 6 – Installation progress

Installation completion dialog

Figure 7 – Installation completion dialog

After installation is complete, open the Neo4j desktop. After reading and accepting the user license agreement, you are asked to paste the activation code generated previously (when downloading Neo4j).

License agreement

Figure 8 – License agreement

Pasting the activation key

Figure 9 – Pasting the activation key

Once the activation key is validated, the sample databases are installed, and the Neo4j main screen appears.

Main screen

Figure 10 – Main screen

You can refer to the Neo4j official documentation to learn more about the main screen’s navigation option.

Starting the Movie graph database

If you want to start learning from scratch, you can create a new project by clicking on the “New” button on the screen’s top left.

Adding a new project

Figure 11 – Adding a new project

This tutorial will be using the Neo4j primer project, which contains a sample database called the “Movie database” that contains information about movies and related people.

First, we should start the Movie graph database by clicking on the “Start” button shown in the image below.

Starting the movie database

Figure 12 – Starting movie database

Once the movie database is active, click on the “Open” button to open it using the Neo4j browser.

Opening the movie database

Figure 13 – Opening the movie database

Neo4j browser

Figure 14 – Neo4j browser

Movie database contains built-in examples. You can create nodes and edges, add properties, and explore your data using interactive slideshows. To get started, enter the following command in the console:

This command will open the movie database example interactive slideshow.

Movie database example interactive slideshows

Figure 15 – Movie database example interactive slideshows

Explaining the Movie database tutorial

In this section, we will explain the main commands that appear in the movie database example.

Creating and switching the current database

To create a new database, you should use the following command:

To switch to the current database, you should use the following command:

To switch to the system database, you should use:

Creating Nodes and Edges

The next step is to add Nodes (entities). If we look at the code shown in the second slide. We can see that there are two types of commands:

  1. Creating Nodes
  2. Creating Edges

The following lines of code are an example of creating nodes:

In the previous code lines, the first line is to add a movie node, and the others are for persons. From those lines, we can see that the node creation command syntax is:

The following lines of codes are an example of creating edges (relations):

From those lines, we can see that the node creation command syntax is:

After running this command we the created graph will be visualized as shown below:

Visualized graph

Figure 16 – Visualized graph

Querying graphs

The rest of the Movie database tutorial contains different examples of data retrieval operations using GraphQL. Note that the MATCH command is used to query data. As an example, to get all movies that Tom Hanks acted in:

Note that the result can be visualized as a graph, text, table, or code:

The Query result

Figure 17 – Query result


In this article, we have explained what graph databases are. Then we talked briefly about the leading graph database called Neo4j. We showed how to download and install it on the Windows operating system and start creating and querying graphs. This was just a brief introduction, we will go deeper in the next articles. You can also refer to this documentation, Neo4j official developer resources to get more details.

Table of contents

Import data from MongoDB to SQL Server using SSIS
Getting started with the Neo4j graph database
Migrating SQL Server graph databases to Neo4j
Export indexes and constraints from SQL Server graph databases to Neo4j
Migrating SQL Server graph databases to ArangoDB
Hadi Fadlallah
Graph database

About Hadi Fadlallah

Hadi is an SQL Server professional with more than 10 years of experience. His main expertise is in data integration. He's one of the top ETL and SQL Server Integration Services contributors at Stackoverflow.com . Also, he published several article series about Biml, SSIS features, Search engines, Hadoop, and many other technologies. Besides working with SQL Server, he worked with different data technologies such as NoSQL databases, Hadoop, Apache Spark. He is a MongoDB, Neo4j, and ArangoDB certified professional. On the academic level, Hadi holds two master's degrees in computer science and business computing. Currently, he is a Ph.D. candidate in data science focusing on Big Data quality assessment techniques. Hadi really enjoys learning new things everyday and sharing his knowledge. You can reach him on his personal website. View all posts by Hadi Fadlallah