Neo4j Database – Part 02 – Basics

In the last blog I introduced Neo4j. In this blog I will cover some of the basics.

Desktop Interface

I installed Neo4j Desktop and then clicked on the icon to launch.

I have to start off and say that the UI is not that impressive. In fact after doing some searching around, there is not any good UI’s that can be used with the latest version at the time of writing. Every action will need to be done by writing Cypher code so it is fair to say that knowing Cypher is a very important requirement for getting the most out of Neo4j. The UI after launch looks like this.

 

Create a New Project

Click on the New link next to Projects to create a project with the default name of Project.

Click the pen icon next to Project and rename to Demo, then click the New Graph link. You get a choice of connecting to an existing database on a target server or just creating a local one.

Click on Create a Local Graph. Call your database FirstDatabase and give it an initial password. Leave the version at the latest and click Create.

You have now created your first empty database

When you clicked on Create, the UI will create the database in location %APPDATA%\ .Neo4jDesktop\neo4jDatabases. The folder name for the database is called database-. You can see a log of this activity in %APPDATA%\.Neo4jDesktop\log.log.

Managing your Database

Click on the Manage link to view the management console. I am not going to go through each option because they are fairly self-explanatory however; here is a link to the Operations Manual. Note: The first time you create a database you will be asked to enter the password for user neo4j. The password is also neo4j and you will be asked to change it. This only occurs the first time.

Launching the UI

Click on the video play button in the top left hand corner to start the database. Once the status shows as Running click on the Open Browser button above to launch the browser UI.

This is the UI you will use to create your database objects and query them. Notice the UI title shows localhost:7687. You can also get the same UI experience using port 7474 however; Neo4j documentation says the 7474 sends data unencrypted and therefore not advisable for production systems.

Administration Command Line

The installation adds a few command line tools. On my installation, these can be found in %APPDATA%\ .Neo4jDesktop\neo4jDatabases\database-f9b1bf6f-2f38-42ba-a541-b5a7090ae216\installation-3.3.4\bin

Neo4j.bat

Tool for starting and stopping Neo4j or managing it as a service.

neo4j-admin.bat

Performs backups, restores, consistency checks, etc.

neo4j-backup.bat

Old deprecated standalone backup command. Use neo4j-admin.bat instead.

neo4j-import.bat

Old deprecated data import command. Use neo4j-admin.bat instead.

neo4j-shell.bat

Command line tool for entering Cypher commands

Administation UI

Before we begin creating our database objects, let’s explore the commands we have available to use for administering the database using the UI. Neo4j recognises the following types of commands:

  • Client-side commands start with a colon :
  • Calling procedures.
  • Cypher query commands

Client-side Commands

At the top of the UI enter the client-side command :help and hit return.

If you try out some of the various help examples, eventually you will see what commands are available. For example; the help lead me to the command:

Here I can manage the users. Notice as you run commands, more and more stacked windows appear below. You can delete them individually or run the command :CLEAR.

Calling Procedures

Procedures are a way to extend the functionality in Neo4j with custom code written in Java. Neo4j Desktop comes with a couple of built-in procedures. Enter CALL db. or CALL dbms. and an intellisence window will appear with the procedures available.


You can call a procedure with or without parameters depending if any are mandatory. E.G. CALL dbms.security.listUsers()

Another way of listing all the procedures available is running the following command. CALL dbms.procedures() YIELD name RETURN name. This will show any custom procedures that have been added.

Cypher Query Commands

These are the query language commands available and will be covered in the blogs when creating and querying our data models.

In the next blog I will discuss the objects in a Neo4j database.