Database Reference
In-Depth Information
Likeallwriteoperationsonthegraphdatabase,thecreationofrelationshipsrequiresarun-
ningtransaction. Thefollowing listing showshowyoucancreate the IS_FRIEND_OF re-
lationship between the user nodes you created earlier.
Listing 3.4. Creating relationships between nodes using the Neo4j Core Java API
Next, we'll identify users in the graph using the name property.
3.2.3. Adding properties to nodes
Neo4j is a directed property graph. Property graph means that every graph entity can have
a number of properties that describe it. Properties are stored as key-value pairs with the
property name as the key referencing the property value. To illustrate the concept of prop-
erties, we're going to show you how to add the name property to the user nodes.
To add a property to a node, you need to call the Node.setProperty(name,
value) method onthetargetnode.Thenextlisting showshowyoucanusetheCoreJava
API to add names to all the users.
Listing 3.5. Adding name property to user nodes
Nowyouhavearichergraphmodel,wheretheusershavenamesyoucandifferentiatethem
by.
 
Search WWH ::




Custom Search