Graph Data Processing with Cypher

Book description

Get acquainted with Cypher in a guided manner quickly and learn how to query the graph databases with efficient and performant queries

Key Features

  • Work with Cypher syntax and semantics while building graph traversal queries
  • Get up and running with advanced Cypher concepts like List, Maps, OPTIONAL MATCH
  • Master best practices in writing effective queries leveraging data modeling and patterns

Book Description

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.

What you will learn

  • Write Cypher queries from basic to advanced level
  • Map the source data to the graph data model in an iterative fashion
  • Load the data into a graph using LOAD CSV, APOC, and client drivers
  • Map the business questions to graph queries effectively
  • Identify query performance issues and fix them
  • Extend capabilities of Cypher using APOC utilities
  • Work with graph visualization tools like Bloom and Browser

Who this book is for

This book is targeted at Database Administrator, 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 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.

Table of contents

  1. Graph Data Processing with Cypher
  2. Contributors
  3. About the author
  4. About the reviewer
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Conventions used
    6. Get in touch
    7. Share Your Thoughts
    8. Download a free PDF copy of this book
  6. Part 1: Cypher Introduction
  7. Chapter 1: Introduction to Neo4j and Cypher
    1. Technical requirements
    2. Introducing Neo4j and graph database concepts
      1. Understanding nodes in graphs
      2. Understanding relationships in graphs
    3. Cypher
    4. Installing Neo4j Desktop
      1. Downloading Neo4j Desktop
    5. A visual tour of Neo4j Desktop
      1. Projects menu
      2. DBMSs menu
      3. Graph applications
      4. Help menu
      5. Settings menu
    6. Using Neo4j Desktop
      1. Creating a local DBMS
      2. Managing a local DBMS instance
    7. Working with a local DBMS
      1. Starting the instance
      2. Opening the browser
      3. Working with the browser’s UI
      4. Working with additional options to manage local DBMS
    8. Summary
  8. Chapter 2: Components of Cypher
    1. Technical requirements
    2. Graph storage in Neo4j
    3. Using the Cypher syntax
      1. Property types
      2. Structural types
      3. Composite types
    4. Using the nodes syntax
    5. Using the relationships syntax
    6. Working with Cypher keywords
      1. Using MATCH and OPTIONAL MATCH
      2. Using CREATE and DELETE
      3. SET and REMOVE
      4. Using WHERE, SKIP, LIMIT, and ORDER BY
      5. Using MERGE
      6. Using FOREACH
      7. Using UNWIND
      8. Using UNION and UNION ALL
      9. Using indexes and constraints
    7. Summary
  9. Part 2: Working with Cypher
  10. Chapter 3: Loading Data with Cypher
    1. Before loading the data
    2. Graph data modeling
    3. Loading data with LOAD CSV
      1. LOAD CSV without headers
      2. LOAD CSV with headers
    4. Loading data with LOAD CSV using batching
      1. USING PERIODIC COMMIT
      2. CALL IN TRANSACTIONS
    5. Loading data using client drivers
      1. URI schemes
      2. Neo4j sessions
    6. Mapping the source data to graph
      1. Loading the patient data
      2. Loading the encounter data
      3. Loading provider data
      4. Loading organization data
      5. Loading medication data
      6. Loading condition, procedure, and allergy data
      7. Loading care plan data
      8. Using client drivers
    7. Summary
  11. Chapter 4: Querying Graph
    1. Exploring the data in Graph
    2. Querying the nodes
    3. Querying the paths
    4. Summary
  12. Chapter 5: Filtering, Sorting, and Aggregations
    1. Filtering with node labels and relationship types
    2. Filtering with WHERE and WITH clauses
    3. Sorting data using the ORDER BY clause
    4. Working with aggregations
    5. Summary
  13. Chapter 6: List Expressions, UNION, and Subqueries
    1. Working with list expressions
      1. Working with the range function
      2. Working with the head function
      3. Working with the tail function
      4. Working with the last function
      5. Working with the size function
      6. Working with the reverse function
      7. Working with the reduce function
      8. Working with list comprehensions
    2. Working with UNION in Cypher
    3. Working with subqueries
      1. Working with returning subqueries
      2. Working with unit subqueries
    4. Summary
  14. Part 3: Advanced Cypher Concepts
  15. Chapter 7: Working with Lists and Maps
    1. Working with lists
      1. Working with basic list capabilities
      2. Working with list operators
      3. Revisiting the list functions
      4. Working with COLLECT and UNWIND
    2. Working with maps
      1. Working with map projections
      2. Combining lists and maps
    3. Summary
  16. Chapter 8: Advanced Query Patterns
    1. Working with the WITH clause
      1. Introducing variables at the start
    2. Working with the CASE clause
      1. Working with simple CASE expressions
      2. Working with generic CASE expressions
    3. Working with the FOREACH clause
    4. Working with the UNWIND clause
    5. Working with count stores
    6. Summary
  17. Chapter 9: Query Tuning
    1. Working with EXPLAIN
    2. Working with PROFILE
    3. Reviewing plan operators
    4. Using index hints
    5. Summary
  18. Chapter 10: Using APOC Utilities
    1. Installing APOC
    2. Working with data import and export
      1. Importing CSV data
      2. Importing JSON data
    3. Viewing database schema
    4. Executing dynamic Cypher
    5. Working with advanced path finding
    6. Connecting to other databases
    7. Using other useful methods
    8. Summary
  19. Chapter 11: Cypher Ecosystem
    1. Using Neo4j extensions
    2. Using visualization tools
    3. Using Kafka and Spark connectors
    4. Using Graph Data Science
    5. Using Neo4j Workspace
    6. Summary
  20. Chapter 12: Tips and Tricks
    1. Understanding the internals of Neo4j
      1. Understanding the node store
      2. Understanding the relationship store
      3. Understanding the property store
      4. Understanding Neo4j memory usage
    2. Reviewing querying patterns
    3. Troubleshooting a few common issues
    4. Reviewing the new 5.0 changes
    5. Summary
  21. Index
    1. Why subscribe?
  22. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: Graph Data Processing with Cypher
  • Author(s): Ravindranatha Anthapu
  • Release date: December 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781804611074