Neo4j in Action
Aleksa Vukotic and Nicki Watt with Tareq Abedrabbo, Dominic Fox, and Jonas Partner
Foreword by Jim Webber and Ian Robinson
  • December 2014
  • ISBN 9781617290763
  • 304 pages
  • printed in black & white

A pragmatic programmatic tour through Neo4j’s APIs and query language.

From the Foreword by Jim Webber and Ian Robinson, Neo Technology

Neo4j in Action is a comprehensive guide to Neo4j, aimed at application developers and software architects. Using hands-on examples, you'll learn to model graph domains naturally with Neo4j graph structures. The book explores the full power of native Java APIs for graph data manipulation and querying.

Table of Contents show full

foreword

preface

acknowledgments

about this book

about the authors

about the cover illustration

Part 1 Introduction to Neo4j

1. A case for a Neo4j database

1.1. Why Neo4j?

1.2. Graph data in a relational database

1.2.1. Querying graph data using MySQL

1.3. Graph data in Neo4j

1.3.1. Traversing the graph

1.4. SQL joins versus graph traversal on a large scale

1.5. Graphs around you

1.6. Neo4j in NoSQL space

1.6.1. Key-value stores

1.6.2. Column-family stores

1.6.3. Document-oriented databases

1.6.4. Graph databases

1.6.5. NoSQL categories compared

1.7. Neo4j: the ACID-compliant database

1.8. Summary

2. Data modeling in Neo4j

2.1. What is a data model for Neo4j?

2.1.1. Modeling with diagrams: a simple example

2.1.2. Modeling with diagrams: a complex example

2.2. Domain modeling

2.2.1. Entities and properties

2.3. Further examples

2.3.1. Underground stations example

2.3.2. Band members example

2.4. Summary

3. Starting development with Neo4j

3.1. Modeling graph data structures

3.2. Using the Neo4j API

3.2.1. Creating nodes

3.2.2. Creating relationships

3.2.3. Adding properties to nodes

3.2.4. Node type strategies

3.2.5. Adding properties to relationships

3.3. Node labels

3.4. Summary

4. The power of traversals

4.1. Traversing using the Neo4j Core Java API

4.1.1. Finding the starting node

4.1.2. Traversing direct relationships

4.1.3. Traversing second-level relationships

4.1.4. Memory usage considerations

4.2. Traversing using the Neo4j Traversal API

4.2.1. Using Neo4j’s built-in traversal constructs

4.2.2. Implementing a custom evaluator

4.3. Summary

5. Indexing the data

5.1. Creating the index entry

5.2. Finding the user by their email

5.3. Dealing with more than one match

5.4. Dealing with changes to indexed data

5.5. Automatic indexing

5.5.1. Schema indexing

5.5.2. Auto-indexing

5.6. The cost/benefit trade-off of indexing

5.6.1. Performance benefit of indexing when querying

5.6.2. Performance overhead of indexing when updating and inserting

5.6.3. Storing the index

5.7. Summary

Part 2 Application Development with Neo4j

6. Cypher: Neo4j query language

6.1. Introduction to Cypher

6.1.1. Cypher primer

6.1.2. Executing Cypher queries

6.2. Cypher syntax basics

6.2.1. Pattern matching

6.2.2. Finding the starting node

6.2.3. Filtering data

6.2.4. Getting the results

6.3. Updating your graph with Cypher

6.3.1. Creating new graph entities

6.3.2. Deleting data

6.3.3. Updating node and relationship properties

6.4. Advanced Cypher

6.4.1. Aggregation

6.4.2. Functions

6.4.3. Piping using the with clause

6.4.4. Cypher compatibility

6.5. Summary

7. Transactions

7.1. Transaction basics

7.1.1. Adding in a transaction

7.1.2. Finishing what you start and not trying to do too much in one go

7.2. Transactions in depth

7.2.1. Transaction semantics

7.2.2. Reading in a transaction and explicit read locks

7.2.3. Writing in a transaction and explicit write locks

7.2.4. The danger of deadlocks

7.3. Integration with other transaction management systems

7.4. Transaction events

7.5. Summary

8. Traversals in depth

8.1. Traversal ordering

8.1.1. Depth-first

8.1.2. Breadth-first

8.1.3. Comparing depth-first and breadth-first ordering

8.2. Expanding relationships

8.2.1. StandardExpander

8.2.2. Ordering relationships for expansion

8.2.3. Custom expanders

8.3. Managing uniqueness

8.3.1. NODE_GLOBAL uniqueness

8.3.2. NODE_PATH uniqueness

8.3.3. Other uniqueness types

8.4. Bidirectional traversals

8.5. Summary

9. Spring Data Neo4j

9.1. Where does SDN fit in?

9.1.2. What is SDN good for (and not good for)?

9.1.3. Where to get SDN

9.1.4. Where to get more information

9.2. Modeling with SDN

9.2.1. Initial POJO domain modeling

9.2.2. Annotating the domain model

9.2.3. Modeling node entities

9.2.4. Modeling relationship entities

9.2.5. Modeling relationships between node entities

9.3. Accessing and persisting entities

9.3.1. Supporting Spring configuration

9.3.2. Neo4jTemplate class

9.3.3. Repositories

9.3.4. Other options

9.4. Object-graph mapping options

9.4.1. Simple mapping

9.4.2. Advanced mapping based on AspectJ

9.4.3. Object mapping summary

9.5. Performing queries and traversals

9.5.1. Annotated queries

9.5.2. Dynamically derived queries

9.5.3. Traversals

9.6. Summary

Part 3 Neo4j in Production

10. Neo4j: embedded versus server mode

10.1. Usage modes overview

10.2. Embedded mode

10.2.1. Core Java integration

10.2.2. Other JVM-based integration

10.3. Server mode

10.3.1. Neo4j server overview

10.3.2. Using the fine-grained Neo4j server REST API

10.3.3. Using the Cypher Neo4j server REST API endpoint

10.3.4. Using a remote client library to help access the Neo4j server

10.3.5. Server plugins and unmanaged extensions

10.4. Weighing the options

10.4.1. Architectural considerations

10.4.2. Performance considerations

10.4.3. Other considerations

10.5. Getting the most out of the server mode

10.5.1. Avoid fine-grained operations

10.5.2. Using Cypher

10.5.3. Server plugins

10.5.4. Unmanaged extensions

10.5.5. Streaming REST API

10.6. Summary

11. Neo4j in production

11.1. High-level Neo4j architecture

11.1.1. Setting the scene …​

11.1.2. Disks

11.1.3. Store files

11.1.4. Neo4j caches

11.1.5. Transaction logs and recoverability

11.1.6. Programmatic APIs

11.2. Neo4j High Availability (HA)

11.2.1. Neo4j clustering overview

11.2.2. Setting up a Neo4j cluster

11.2.3. Replication—reading and writing strategies

11.2.4. Cache sharding

11.2.5. HA summary

11.3. Backups

11.3.1. Offline backups

11.3.2. Online backups

11.3.3. Restoring from backup

11.4. Topics we couldn’t cover but that you should be aware of

11.4.1. Security

11.4.2. Monitoring

11.5. Summary

11.6. Final thoughts

Appendix A: Installing Neo4j server

A.1. Installing and configuring a single Neo4j server

A.2. Neo4j browser

A.3. Neo4j Web Admin Console

Appendix B: Setting up and running the sample code

B.1. Setting up your environment

B.2. Running the demos and samples

Appendix C: Setting up your project to use SDN

C.1. Maven configuration

C.2. Spring configuration

Appendix D: Getting more help

index

About the Technology

Much of the data today is highly connected—from social networks to supply chains to software dependency management—and more connections are continually being uncovered. Neo4j is an ideal graph database tool for highly connected data. It is mature, production-ready, and unique in enabling developers to simply and efficiently model and query connected data.

About the book

Neo4j in Action is a comprehensive guide to designing, implementing, and querying graph data using Neo4j. Using hands-on examples, you'll learn to model graph domains naturally with Neo4j graph structures. The book explores the full power of native Java APIs for graph data manipulation and querying. It also covers Cypher, Neo4j's graph query language. Along the way, you'll learn how to integrate Neo4j into your domain-driven app using Spring Data Neo4j, as well as how to use Neo4j in standalone server or embedded modes.

What's inside

  • Graph database patterns
  • How to model data in social networks
  • How to use Neo4j in your Java applications
  • How to configure and set up Neo4j

About the reader

Knowledge of Java basics is required. No prior experience with graph data or Neo4j is assumed.

About the authors

Aleksa Vukotic is an architect specializing in graph data models. Nicki Watt, Dominic Fox, Tareq Abedrabbo, and Jonas Partner work at OpenCredo, a Neo Technology partner, and have been involved in many projects using Neo4j.


combo $44.99 pBook + eBook
eBook $35.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

Excellent coverage of one of the most successful NoSQL products.

Pouria Amirian, PhD, University of Oxford

A great resource for rethinking your data storage using graphs in Neo4j.

Stephen Kitt, ERDF