Database Reference
In-Depth Information
We'll refer to these relationships as
rich relationships
because of the additional data they
contain over and above the relationship type.
The
HAS_SEEN
relationship is a perfect example of this, with its additional
stars
prop-
erty providing more context to the relationship. It indicates not just that a user has seen a
movie, but also how the user rated it. In the social network model, this relationship with
understand the relationship between two users—that is, that they're friends. These
simple
relationships
(relationships wherethe
TYPE
alone isenoughtocompletely describe there-
lationship, such as the
IS_FRIEND_OF
relationship) can still be referenced, and you'll
see how this is done in
section 9.2.5
, but there's no additional benefit in defining a whole
new class to represent them.
Listing 9.3. The
Viewing
class as a relationship entity
The
@RelationshipEntity
annotation is applied to classes to indicate that it repres-
ents a Neo4j relationship. The annotation takes a
type
property that indicates the name of
the Neo4j relationship type used within the graph itself. If the
type
property is not expli-
citlyspecifiedwithintheannotation,SDNwilldefaultthevalueassignedtoitasthesimple
name of the class (which would be
Viewing
in this example). As with the node entity,
the relationship entity has the same requirement for a
@GraphId
annotated field
, this
time for storing the underlying relationship ID.