Database Reference
In-Depth Information
Chapter 3. Starting development with Neo4j
This chapter covers
• Modeling graph data
• Creating connected nodes using the Neo4j Java API
• Adding additional information to nodes and relationships using properties
• Strategies for differentiating between types of nodes
In chapter 1 wedemonstratedtheperformanceandscalability improvementsavailablewhen
using Neo4j as a database for graph data. We also discussed how data that's naturally
modeled as a graph fits well with the Neo4j data model. Now it's time to get some hands-on
practice.
In this chapter we'll introduce you to the Neo4j Core Java API by modeling and creating an
examplegraphintheNeo4jgraphdatabase.We'llbuildonthesocialnetworkexamplefrom
chapter 1 , but we'll make it slightly more complex by allowing users to rate movies they've
seen.
The users in the social network can be friends. In addition, users can mark the movies
they've seen and rate them with one to five stars based on how much they liked them.
In the first part of this chapter, we're going to model the requirements for this example
using a series of diagrams, simulating the software design process. In the second part, we'll
demonstrate how to create the same social network using the Neo4j Core Java API.
3.1. Modeling graph data structures
Before we dig into the world of Neo4j, let's model the social network domain as a generic
graph. If you were doing modeling in your office, you'd probably draw the model on a
whiteboard. We'll illustrate the whiteboard modeling with figures throughout this chapter.
First, you need a few users in your social network. The users are represented as boxes, as in
figure 3.1 .
Search WWH ::




Custom Search