Graph Data Processing with Cypher - Ravindranatha Anthapu - E-Book

Graph Data Processing with Cypher E-Book

Ravindranatha Anthapu

0,0
28,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

While it is easy to learn and understand the Cypher declarative language for querying graph databases, it can be very difficult to master it. As graph databases are becoming more mainstream, there is a dearth of content and guidance for developers to leverage database capabilities fully. This book fills the information gap by describing graph traversal patterns in a simple and readable way.
This book provides a guided tour of Cypher from understanding the syntax, building a graph data model, and loading the data into graphs to building queries and profiling the queries for best performance. It introduces APOC utilities that can augment Cypher queries to build complex queries. You’ll also be introduced to visualization tools such as Bloom to get the most out of the graph when presenting the results to the end users.
After having worked through this book, you’ll have become a seasoned Cypher query developer with a good understanding of the query language and how to use it for the best performance.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 280

Veröffentlichungsjahr: 2022

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Graph Data Processing with Cypher

A practical guide to building graph traversal queries using the Cypher syntax on Neo4j

Ravindranatha Anthapu

BIRMINGHAM—MUMBAI

Graph Data Processing with Cypher

Copyright © 2022 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Publishing Product Manager: Arindam Majumder

Content Development Editor: Priyanka Soam

Technical Editor: Sweety Pagaria

Copy Editor: Safis Editing

Project Coordinator: Farheen Fathima

Proofreader: Safis Editing

Indexer: Subalakshmi Govindhan

Production Designer: Aparna Bhagat

Marketing Coordinators: Priyanka Mhatre, Nivedita Singh

First published: November 2022

Production reference: 1301122

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-80461-107-4

www.packt.com

I would like to dedicate this book to my lovely wife, Sreevani Rajuru, for all her encouragement and patience during this journey

Contributors

About the author

Ravindranatha Anthapu has more than 25 years of experience in working with W3C standards and building cutting-edge technologies, including integrating speech into mobile applications in the 2000s. He is a technology enthusiast who has worked on many projects, from operating system device drivers to writing compilers for C language and modern web technologies, transitioning seamlessly and bringing experience from each of these domains and technologies to deliver successful solutions today. As a principal consultant at Neo4j today, Ravindranatha works with large enterprise customers to make sure they are able to leverage graph technologies effectively across various domains.

About the reviewer

Koji Annoura has over 40 years of experience as a full stack developer. He has been working in Agile software development since 2009 and is one of the founders of the Tokyo Neo4j User Group in Japan.

He is a Neo4j Ninja, Graph Community MVP, and Neo4j Speaker, and he founded the Apache Hop User Group Japan in 2021. He has been involved in the Agile transformation of many companies and teams and has been involved in the implementation of Agile and Scrum. He likes Star Trek (Trekie) and has given presentations about the Klingon language. More information on the Neo4j Ninja program can be found here: https://community.neo4j.com/t5/ninjas-program/ct-p/ninjas.

Sean William Grant is a product and analytics professional with over 20 years of experience in technology and data analysis. His experience ranges from geospatial intelligence with the United States Marine Corps, product management within the aviation and autonomy space, to implementing advanced analytics and data science within organizations. He is a graph data science and network analytics enthusiast who frequently gives presentations and workshops on connected data. He has also been a technical advisor to several early-stage startups. Sean is passionate about data and technology, and how it can elevate our understanding of ourselves.

Table of Contents

Preface

Part 1: Cypher Introduction

1

Introduction to Neo4j and Cypher

Technical requirements

Introducing Neo4j and graph database concepts

Understanding nodes in graphs

Understanding relationships in graphs

Cypher

Installing Neo4j Desktop

Downloading Neo4j Desktop

A visual tour of Neo4j Desktop

Projects menu

DBMSs menu

Graph applications

Help menu

Settings menu

Using Neo4j Desktop

Creating a local DBMS

Managing a local DBMS instance

Working with a local DBMS

Starting the instance

Opening the browser

Working with the browser’s UI

Working with additional options to manage local DBMS

Summary

2

Components of Cypher

Technical requirements

Graph storage in Neo4j

Using the Cypher syntax

Property types

Structural types

Composite types

Using the nodes syntax

Using the relationships syntax

Working with Cypher keywords

Using MATCH and OPTIONAL MATCH

Using CREATE and DELETE

SET and REMOVE

Using WHERE, SKIP, LIMIT, and ORDER BY

Using MERGE

Using FOREACH

Using UNWIND

Using UNION and UNION ALL

Using indexes and constraints

Summary

Part 2: Working with Cypher

3

Loading Data with Cypher

Before loading the data

Graph data modeling

Loading data with LOAD CSV

LOAD CSV without headers

LOAD CSV with headers

Loading data with LOAD CSV using batching

USING PERIODIC COMMIT

CALL IN TRANSACTIONS

Loading data using client drivers

URI schemes

Neo4j sessions

Mapping the source data to graph

Loading the patient data

Loading the encounter data

Loading provider data

Loading organization data

Loading medication data

Loading condition, procedure, and allergy data

Loading care plan data

Using client drivers

Summary

4

Querying Graph

Exploring the data in Graph

Querying the nodes

Querying the paths

Summary

5

Filtering, Sorting, and Aggregations

Filtering with node labels and relationship types

Filtering with WHERE and WITH clauses

Sorting data using the ORDER BY clause

Working with aggregations

Summary

6

List Expressions, UNION, and Subqueries

Working with list expressions

Working with the range function

Working with the head function

Working with the tail function

Working with the last function

Working with the size function

Working with the reverse function

Working with the reduce function

Working with list comprehensions

Working with UNION in Cypher

Working with subqueries

Working with returning subqueries

Working with unit subqueries

Summary

Part 3: Advanced Cypher Concepts

7

Working with Lists and Maps

Working with lists

Working with basic list capabilities

Working with list operators

Revisiting the list functions

Working with COLLECT and UNWIND

Working with maps

Working with map projections

Combining lists and maps

Summary

8

Advanced Query Patterns

Working with the WITH clause

Introducing variables at the start

Working with the CASE clause

Working with simple CASE expressions

Working with generic CASE expressions

Working with the FOREACH clause

Working with the UNWIND clause

Working with count stores

Summary

9

Query Tuning

Working with EXPLAIN

Working with PROFILE

Reviewing plan operators

Using index hints

Summary

10

Using APOC Utilities

Installing APOC

Working with data import and export

Importing CSV data

Importing JSON data

Viewing database schema

Executing dynamic Cypher

Working with advanced path finding

Connecting to other databases

Using other useful methods

Summary

11

Cypher Ecosystem

Using Neo4j extensions

Using visualization tools

Using Kafka and Spark connectors

Using Graph Data Science

Using Neo4j Workspace

Summary

12

Tips and Tricks

Understanding the internals of Neo4j

Understanding the node store

Understanding the relationship store

Understanding the property store

Understanding Neo4j memory usage

Reviewing querying patterns

Troubleshooting a few common issues

Reviewing the new 5.0 changes

Summary

Index

Other Books You May Enjoy

Preface

Cypher is a declarative language to query graph databases. As graph databases are becoming more mainstream, there is a dearth of content and guidance for developers to leverage the database capabilities fully. This book is an attempt to fill that information gap. It is well suited to describe graph traversal patterns in a simple and readable manner. While it is easy to learn and understand, it can be very difficult to master.

This book provides a guided tour of Cypher language from understanding the syntax of the language, building a graph data model, loading the data into graphs, building queries, and profiling the queries for best performance. It introduces APOC utilities that can augment the Cypher queries to build complex queries. It also introduces visualization tools such as Bloom to get the most out of the graph when presenting the results to the end users.

By the end of this book, you should be a seasoned Cypher query developer with a good understanding of the query language and how to get the best performance out of it.

Who this book is for

This book is targeted at database administrators, database developers, graph database developers, and graph database architects. This book will also help someone migrate from a DBA role to a graph data engineer or data scientist role.

If you are working with graph databases and need to learn Cypher, or are a basic Cypher developer who wants to get better at data modeling and tuning queries to build performant Cypher queries, then this is the book for you.

What this book covers

Chapter 1, Introduction to Neo4j and Cypher, introduces Cypher and Neo4j. We discuss what the Cypher language is and how it is used to query the Neo4j graph database. We also take a look at how Cypher is different from other query languages and what sets it apart for querying graph databases.

Chapter 2, Components of Cypher, introduces the Cypher syntax with some examples. We will review the important aspects of the Cypher syntax and semantics in building graph traversal queries. We will discuss important keywords and the role they play in building the queries. We will take a look at the graph data model and how Cypher queries follow the data connections.

Chapter 3, Loading Data with Cypher, explains how to load the data into Neo4j using Cypher. We will discuss the various options available to create/update/delete the nodes, labels, relationships, and properties. We will discuss loading CSV, text and JSON files into Neo4j using Cypher.

Chapter 4, Querying Graph, discusses how querying works with Cypher. It discusses leveraging indexes on nodes and relationships to anchors and traversals. It also discusses conditional traversals, using multiple relationship types, returning paths, nodes, relationships, and so on. It also talks about returning the data as column-formatted data.

Chapter 5, Filtering, Sorting, and Aggregations, discusses how to filter the data using where conditions on nodes and/or relationship properties, and how to sort the data and use aggregation functions such as SUM, AVG, COUNT, and so on.

Chapter 6, List Expressions, UNION, and Subqueries, talks about using list expressions to reduce and process lists. It also explores how UNIONs can be used to return combined results from multiple queries along with leveraging subqueries to filter and process data.

Chapter 7, Working with Lists and Maps, explains how lists and maps are core elements in Cypher. This chapter discusses how we can handle lists and maps both as an input and as an output. It shows how easy it is to handle lists and maps as part of the querying process. It shows how to handle basic lists with Strings and also how to access individual elements at random or iterate through them.

Chapter 8, Advanced Query Patterns, discusses advanced concepts such as OPTIONAL MATCH to handle scenarios where the graph path may or may not exist. It also discusses the query chain using WITH and UNWIND. It also talks about executing subqueries using the CALL keyword and handling the responses in the main query.

Chapter 9, Query Tuning, talks about options to tune the Cypher queries. It talks about working with EXPLAIN PLAN to understand the query execution plan. It also talks about using PROFILE to understand how the query is executing and the amount of data being processed to understand the reasons for bottlenecks.

Chapter 10, Using APOC Utilities, talks about using APOC utilities to extend the built-in capabilities of Cypher. It gives more options to be able to load CSV and JSON data, schedule timers, make ad hoc batch data modifications, and so on.

Chapter 11, Cypher Ecosystem, talks about the Cypher ecosystem. It introduces you to tools and packages available to do more advanced data processing along with visualizing the results as graphs, tables, and so on.

Chapter 12, Tips and Tricks, talks about the best practices to get the most out of Cypher queries, which includes how to leverage data modeling and patterns. It also discusses the tips and tricks to identify performance bottlenecks and how to go about addressing them.

To get the most out of this book

There is no need to have RDBMS querying experience or a good understanding of graphs to get the most out of this book. Familiarity with databases and SQL will help in understanding some of the Cypher concepts and tuning approaches.

Software/hardware covered in the book

Operating system requirements

Neo4j Desktop and Neo4j Database Server

Windows, macOS, or Linux

Note

All the Cypher code used in this book has been tested on Neo4j version 4.4.8 but should work with the latest Neo4j 5.0 release.

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

You can join the Neo4j community at https://community.neo4j.com to get answers to most Cypher or Neo4j-related questions. There is a huge developer community that answers all the basic syntax to modeling-related questions.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Cypher-Querying. If there’s an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are several text conventions used throughout this book.

Code in text: Indicates code words in the text, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “we are using the apoc procedure to add EncounterClass to an encounter node. Since we are trying to add labels dynamically, we have to use the apoc option.”

A block of code is set as follows:

CREATE (p {name: 'Tom'}) RETURN p

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold: “The Cypher query looks like this:

MATCH (d:Drug)<-[:HAS_DRUG]-()<-[:HAS_ENCOUNTER]-(p) WITH DISTINCT d, p WITH d.description as drug, count(p) as patientsWHERE patients > 100 RETURN drug, patients

Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “In particular, the addition of a new Encounter node and the HAS_END relationship are a bit different from how we approach data in the RDBMS world.”

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share Your Thoughts

Once you’ve read Graph Data Processing with Cypher, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Download a free PDF copy of this book

Thanks for purchasing this book!

Do you like to read on the go but are unable to carry your print books everywhere? Is your eBook purchase not compatible with the device of your choice?

Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application. 

The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

Follow these simple steps to get the benefits:

Scan the QR code or visit the link below

https://packt.link/free-ebook/9781804611074

Submit your proof of purchaseThat’s it! We’ll send your free PDF and other benefits to your email directly

Part 1: Cypher Introduction

This part introduces you to Neo4j and the origins of Cypher. By the end of this part, you will be able to set up a Neo4j database and understand how Cypher is used to interact with the Neo4j database. It also introduces the core concepts of Cypher and graph databases.

This section comprises the following chapters:

Chapter 1, Introduction to Neo4j and CypherChapter 2, Components of Cypher

1

Introduction to Neo4j and Cypher

Neo4j is the world’s leading graph database. Its architecture is optimized to store, retrieve, and traverse graphs as nodes and relationships. It takes a property graph approach, which is beneficial for fast traversals and operations.

Neo4j uses Cypher as its query language, which makes it easy to represent traversals. Cypher is a declarative language for describing visual patterns in graphs using ASCII-art-like syntax. This makes it easy to read and comprehend how the data is connected as nodes and relationships in graphs.

In this chapter, we will cover the following topics:

Introducing Neo4j and graph database conceptsInstalling the Neo4j DesktopA visual tour of Neo4j DesktopUsing Neo4j DesktopWorking with local DBMSs

If you are already familiar with these basic concepts and are comfortable using Neo4j Desktop and Browser, you can skip this chapter and move on to the next ones.

Technical requirements

You need a Windows, Mac, or Linux machine to be able to download and install Neo4j Desktop. Neo4j Desktop comes pre-packaged with all the required software dependencies.

Introducing Neo4j and graph database concepts

In this section, we will take a look at how data is stored as a graph in Neo4j. We will first introduce what a graph is, what a graph consists of, and how we can query graphs.

Neo4j uses a property graph data model to store the data. The following diagram shows a sample graph created in Neo4j:

Figure 1.1 – Sample graph

Neo4j property graphs can consist of the following features:

Nodes, which describe the entities of a domain.Nodes can have zero or more labels, but a node with no labels is not a normal occurrence. A node with multiple labels represents multiple facets that the node is part of. For example, a node that has labels such as Employee and Manager means this node is an employee who is also a manager.A relationship is a connection between two nodes.Relationships always have a direction, which is represented using an arrow symbol. The node at the starting point of the arrow is called the start node and the node at the end is called the target node.Relationships should have a type, which describes the relationship between the two nodes.Both nodes and relationships can have properties, which are key-value pairs.

Let’s take a look at what nodes represent in a graph.

Understanding nodes in graphs

A node is used to represent an entity in the data domain. A sample node in an HR data domain might be as shown in the following figure:

Figure 1.2 – A node in a graph

This node represents a person in an HR data domain. It has two labels. A label can be thought of as something that describes what this node data represents. Here, the labels are Employee and Manager. This can be interpreted as the node representing an employee who is also a manager, with the firstName, lastName, and joinDate properties.

Let’s take a look at what relationships represent in a graph.

Understanding relationships in graphs

A relationship describes how a source node and a target node are related. It is possible for a node to have a relationship with itself.

A relationship has thefollowing aspects:

It joins a source node and a target node, symbolizing the relationship between these nodes.It has a direction, which can be either incoming or outgoing. It represents the relationship direction of the nodes it is connecting.It has a type, which represents the nature of the connection between the nodes.It can have properties (key-value pairs), which further describe the relationship.

The following diagram represents relationships between employee nodes in HR data:

Figure 1.3 – Relationships between employee nodes

Figure 1.3 represents an employee named John Doe who reports to a manager named Tom Riddle. The REPORTS_TO string is the type of relationship between the two nodes. The direction of the relationship shows the direction of reporting structure. A relationship can also have properties that can further quantify the type of relationship between the two nodes.

Cypher

Nodes typically represent entities, such as concepts, events, places, and so on. Relationships connect the nodes that represent the context of how those two nodes are related. They can be considered as building blocks of the graph. The real strength of a property graph lies in its simplicity when it comes to representing and traversing patterns in graphs in an efficient manner.

Cypher is a query language based on graph traversal descriptions. These patterns are used to match the desired graph paths. When the matching pattern has been found, it can be used for further processing.

A simple pattern in Cypher is shown as follows:

(p:Person {name: "Tom"})–[:LIVES_IN]->        (city:City {name: "Edison"})–[:PART_OF]->        (country:Country {name: "United States"} )

The pattern here is self-explanatory and human-readable. A person named Tom lives in a city named Edison, which is a part of the country named the United States. You can see here that nouns represent the nodes and verbs represent the relationships.

We will take a deeper look at Cypher syntax in the coming chapters.

Installing Neo4j Desktop

Neo4j Desktop is a client application that makes it easy for developers to quickly start working with Neo4j databases. This makes it easier to set up and play with Neo4j databases, along with becoming familiar with other tools for developers. Neo4j Desktop allows the user to create multiple servers as needed and work with them in a seamless manner. This makes it easier to update the configuration of DataBase Management Systems (DBMSs), manage plugins, view the logs, backup and restore data, and upgrade the existing DBMS instances.

Downloading Neo4j Desktop

Neo4j Desktop can be downloaded from the Neo4j website, https://neo4j.com/download/.

The system requirements to install the Neo4j desktop are shown in the following table:

Software requirements:

macOS

10.10 (Yosemite)

Ubuntu

12.04+

Fedora

21

Debian

8

Windows

8.1+, with PowerShell 5.1+

Figure 1.4 – System requirements for Neo4j Desktop

Neo4j comes bundled with Java 17, Java 11, and Java 8, along with Neo4j Browser and the Bloom visualization plugin.

Figure 1.5 – Neo4j Desktop download

Next, follow the steps to download Neo4j Desktop:

Click on the Download Desktop button to register and download Neo4j Desktop. This will take you to the registration screen.

Figure 1.6 – User registration screen

Fill out the form with your details. You will need to register with an email to download. You will receive an activation key once registration is complete, as shown in the following figure. This activation key will also be emailed to the email address you have provided.

Figure 1.7 – Neo4j Desktop Activation Key

Now that we have downloaded the Neo4j Desktop binary and acquired the activation key, let us continue with installation.

The installation steps are as follows:

Double-click on the downloaded file to start the installation.

Figure 1.8 – End user license agreement

Accept the terms and conditions by clicking on the I Agree button. You are only asked to do this the first time Neo4j Desktop is installed.

Figure 1.9 – Selecting an installation location

Select the installation location and click Confirm.

Figure 1.10 – Activating Desktop with a software key

Take the software key, paste it into the software key box, and click on Activate.

Figure 1.11 – Installation progress

Neo4j Desktop will continue setting up a first-time environment and creates a starter database when installation is complete. Neo4j Desktop is now ready for use.

A visual tour of Neo4j Desktop

Let’s have a visual tour of the Neo4j Desktop. The following screenshot shows the screen after Neo4j Desktop has launched successfully. The arrows and text point to various sections of the Desktop UI. We will explore each of those sections shortly.

Figure 1.12 – Neo4j Desktop start screen

Let’s move on to the Projectsmenu next.

Projects menu

A project in Neo4j Desktop is a representation of a development folder. You can create local database instances, known as DBMSs, or connect to remote DBMSs, and add files within your project. This allows you to manage multiple projects, and it is easy to move databases and files between different projects using the drag and drop method. At any given point in time, you can have only one active local DBMS or remote connection.

DBMSs menu

A DBMS is a Neo4j server instance that contains a minimum of the system database and a default database. When a DBMS is created, a default database named Neo4j is made. This can be renamed, or a new database can be created.

This screenshot shows all the versions of Neo4j servers that are available to create instances using Neo4j Desktop, along with how many instances of each version exist.

Figure 1.13 – DBMSs menu

Neo4j Desktop includes a free Neo4j Enterprise license for developers to explore all the enterprise capabilities, such as multiple databases, role-based access controls, and so on.

Graph applications

When you click on the graph applications icon in Neo4j Desktop, it will show a list of the graph applications installed.

The following figure shows the graph applications that are available in Neo4j Desktop:

Figure 1.14 – Graph applications

Neo4j Desktop comes with the Neo4j Browser and Bloom applications pre-packaged to help you interact with graphs.

When you click on Graph Apps Gallery, it will take you to the site to explore and install other graph apps.

Help menu

When the help menu is clicked, Neo4j Desktop shows all the forms of help available, as shown in the following screenshot:

Figure 1.15 – Help menu

This section contains the links for Neo4j documentation and resources for developers.

Settings menu

When you click on the settings menu icon, Neo4j Desktop shows the menu that controls Neo4j Desktop operations. The following figure shows which aspects of Neo4j Desktop users can control and change.

Figure 1.16 – Application settings menu

Users can control whether to send crash reports and usage statistics to Neo4j. If Store DBMS passwords is checked, then the user ID and passwords are stored securely, so that you don’t need to enter them every time the Neo4j server is restarted.

In some enterprise environments, you might have to configure a proxy for Neo4j Desktop to be able to go to the internet to download updates and install graph apps and the latest Neo4j server software.

Now that we have talked about the UI control elements of Neo4j Desktop, the next section will discuss using these elements to create a Neo4j instance and manage it.

Using Neo4j Desktop

In this section, we will take a look at how we can use Neo4j Desktop to create a Neo4j instance and manage it.

Creating a local DBMS

Let’s go through the steps to create a local DBMS:

To create a local DBMS, a project should be created and selected.

Figure 1.17 – Creating a local DBMS

Click on the Add button and select Local DBMS to create a local DBMS instance.

Figure 1.18 – Select the Neo4j version

You can change the name from Graph DBMS to anything that makes sense. You will need to provide a password. This would be the password for the Neo4j admin user.In the Version dropdown, Neo4j Desktop shows the latest downloaded version as the selected one and, if there are newer versions, they are also shown in the dropdown with a download icon next to them. This means this version is not available locally and needs to be downloaded. If you would like to use any of those versions, then click on the download icon. This will download that version of the Neo4j software before creating the local DBMS instance.Once the required version is selected, click the Create button to create the local instance.

Next, we will take a look at how we can manage the instance we have created.

Managing a local DBMS instance

Once we have created the local database instance, we can then manage that instance. We can start/stop the instance, change the configuration, and add plugins. Here, we will take a look at how to manage the local Neo4j instance we created.

Reviewing DBMS details

Once the instance is created, an entry is shown in the selected project. The following screenshot shows the instance details:

Figure 1.19 – Local instance details

When you click on the name of the instance, it shows the details on the right-hand side. The description box can be used to add details about this DBMS instance. If you need to change the password, it can be done under the Reset DBMS password option.

Managing DBMS plugins

For this instance, we can add or remove plugins. To do this, click on the Plugins tab. It displays all the installed plugins and the available plugins to install. The following screenshot captures this aspect:

Figure 1.20 – Plugins installation

The list of the plugins available is dependent on the version of the Neo4j instance. When you click on the name of the plugin, it shows the details of that plugin and any related links. You can click on the Install button to install a plugin. Neo4j Desktop will install the plugin and make the required changes to the server configuration.

Upgrading the server

It is possible to upgrade the version of the instance we have created. When you click on the Upgrade tab, it shows the options available. The following screenshot captures this aspect:

Figure 1.21 – Upgrade options

Here, you will find a dropdown of all possible versions of this instance that can be upgraded. When a version is selected, the release notes for that version are shown. By clicking the Upgrade button, you can upgrade the selected DBMS instance.

Working with a local DBMS

This section discusses how you can work with a local Database Management System (DBMS) instance. We can perform multiple operations on an instance. We can start a stopped instance and once an instance is started, we can launch the browser and work with the database instance.

Starting the instance

When an instance is selected in a project, it will show the buttons to start the instance. The following screenshot showcases this:

Figure 1.22 – Starting the instance

Click on the Start button to start the instance.

Opening the browser

When the instance is available to query, the Open button will be activated. The following screenshot demonstrates this:

Figure 1.23 – Opening the browser

Click on the Open button to open the browser. If you need to create another database, you can use the Create Database button to create a new database on this instance. By default, a database named neo4j will be created.

Working with the browser’s UI

The browser looks as shown in the following screenshot. It can be used to query the database.

Figure 1.24 – Neo4j Browser

The Neo4j Browser interface is used to execute Cypher queries against a database:

On the left side of the Neo4j Browser interface, you can see the database details. The dropdown shows the active database that is selected. It can be changed by clicking on the dropdown and selecting the required database.Below the dropdown, you can see the number of nodes, node labels, relationships, relationship types, and property types. You can click on the name of the node labels or relationship types to sample data.Below the database stats section, there are the current user details and user management shortcuts to create, update, or delete local users. It also gives a shortcut to disconnect from DBMS.The DBMS section shows the current DBMS version and shortcut links to get the DBMS details, such as a list of databases available, current queries being executed, and system information.

The query area is where Cypher queries are written. Click on the blue arrow to execute the query. The results will be shown below the query area.

Using Browser help

To get help with browser usage, you can enter :help in the query area. Neo4j Browser will show all the commands available with descriptions, as shown by the following figure:

Figure 1.25 – Browser help

If you scroll down, you will see links for various guides for sample graphs to play with. When you click on the link, you get a guided tour of content that the user can follow by clicking along the way. Here are some sample graph concepts and Cypher guides to illustrate how it works:

Figure 1.26 – Graph concepts

The graph concepts guide provides basic concepts for the user to review before working with Cypher. For new graph database users, this would be a very valuable guide to follow to review the basic concepts.

Figure 1.27 – Cypher help

The Cypher help guide introduces keywords and the basic usage of building queries using these keywords. For new users, this provides a good introduction to Cypher in a quick and clean fashion.

Next, we will take a look at the administrative aspect of the local instance.

Working with additional options to manage local DBMS

We will take a look at administrative