Database Reference
In-Depth Information
Figure 9.5. A social network model with the relationship references between nodes highlighted
From the node entity's perspective, relationships are also modeled as normal Java object
references, and they come in a variety of flavors depending on what you're trying to
convey. We've already previewed how you can use the
Viewing
class to reference the
HAS_SEEN
relationship, but let's tackle the other simpler relationships as well, such as
referredBy
and
IS_FRIEND_OF
.
The relationships involved in the
User
and
Movie
entities are shown in the next listing.
Listing 9.5.
User
and
Movie
node entity snippets
Basic
relationships, represented by an underlying Neo4j relationship with no associated
properties toexactly zerooroneothernodeentity,canbemodeled asastandardobject ref-
erencewithinthenodeentity.Bydefault,thepropertynamewillbeusedasthenamethat's
mapped to the relationship type in Neo4j, in the absence of any meta-information to the
contrary. The newly introduced concept of one user referring another to the social network