Neo4j Graph Data Modeling

Book description

Design efficient and flexible databases by optimizing the power of Neo4j

In Detail

Neo4j is a graph database that allows you to model your data as a graph and find solutions to complex real-world problems that are difficult to solve using any other type of database.

This book is designed to help you understand the intricacies of modeling a graph for any domain.

The book starts with an example of a graph problem and then introduces you to modeling non-graph problems using Neo4j. Concepts such as the evolution of your database, chains, access control, and recommendations are addressed, along with examples and are modeled in a graph. Throughout the book, you will discover design choices and trade-offs, and understand how and when to use them. By the end of the book, you will be able to effectively use Neo4j to model your database for efficiency and flexibility.

What You Will Learn

  • Translate a problem domain from a whiteboard to your database
  • Make design decisions based on the nature of data and how it is going to be used
  • Use Cypher to create and query data
  • Evolve your database in stages
  • Optimize the performance of your application with data design
  • Design paradigms to ensure flexibility, ease of querying, and performance
  • Move from an existing model to a new model without losing consistency

Table of contents

  1. Neo4j Graph Data Modeling
    1. Table of Contents
    2. Neo4j Graph Data Modeling
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. eBooks, discount offers, and more
        6. Questions
    8. 1. Graphs Are Everywhere
      1. Graphs in mathematics
      2. The property graph model
      3. Storage – native graph storage versus non-native graph storage
      4. Reasons to use graph databases
      5. What to use a graph database for
      6. Choosing Neo4j for exploring graph databases
      7. The structure of the book
      8. Summary
    9. 2. Modeling Flights and Cities
      1. Graphs are more than social
      2. Designing a system to get a travel itinerary
        1. Introduction to modeling flights and cities
        2. Identifying the entities
      3. Introduction to modeling nodes and relationships
      4. Using Cypher to operate on Neo4j
      5. Creating cities in Neo4j
      6. Indices
      7. Adding flights to Neo4j
      8. Traversing relationships
      9. Summary
    10. 3. Formulating an Itinerary
      1. Creating an itinerary from flights and cities
        1. Information and paths
        2. Using Cypher to find a path
      2. Business logic should lie in code
      3. Summary
    11. 4. Modeling Bookings and Users
      1. Building a data model for booking flights
      2. A simple model of the bookings ecosystem
      3. Modeling bookings in an RDBMS
      4. Creating bookings and users in Neo4j
        1. Creating users
        2. Creating bookings in Neo4j
      5. Queries to find journeys and bookings
        1. Finding all journeys of a user
      6. Queries to find the booking history of a user
        1. Upcoming journeys of a user
      7. Summary
    12. 5. Refactoring the Data Model
      1. Capturing information about hotels at airports
      2. Modeling airports and hotels
      3. Extracting airport information from flights
        1. Breaking airports out as a node
        2. Connecting flights to airports
        3. Delinking flights and cities
        4. Querying the refactored data model
      4. Reasons for not migrating using a single query
      5. Adding hotels to airports
      6. Fetching hotels
      7. Summary
    13. 6. Modeling Communication Chains
      1. Capturing traveler reviews for hotels
      2. A model for reviews and comments
      3. Adding reviews to Neo4j
        1. Listing reviews for a hotel
        2. Using reviews to find the average rating of a hotel
      4. Adding comments to Neo4j
        1. Considerations for modeling temporal data as chains
      5. Summary
    14. 7. Modeling Access Control
      1. Controlling access for content change
      2. Modeling hierarchies
        1. Modeling geographical regions
          1. Adding countries and regions to Neo4j
        2. Modeling hotel chains
          1. Adding hotel chains to Neo4j
      3. Modeling access control groups and employees
        1. Adding access groups to Neo4j
        2. Adding employees to Neo4j
      4. Querying the data model to find what is accessible to an employee
      5. Summary
    15. 8. Recommendations and Analysis of Historical Data
      1. Recommending cities to travelers
        1. Modeling categories
          1. Creating categories in Neo4j
          2. Cities and categories
        2. Recommending cities based on previous travels
        3. Recommending cities on the basis of other travelers
      2. Recommending hotels to travelers
        1. Recommending hotels from the same chains
        2. Recommending hotels visited by similar travelers
        3. Recommending hotels that match a price range
        4. Improving recommendations
      3. Analysis of the historical data
        1. Querying to discover patterns
      4. Summary
    16. 9. Wrapping Up
      1. There is no correct model
      2. Further reading and exploration
      3. What to watch out for while using Neo4j
    17. Index

Product information

  • Title: Neo4j Graph Data Modeling
  • Author(s): Mahesh Lal
  • Release date: July 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781784393441