O'Reilly logo

Learning Neo4j 3.x - Second Edition by Rik Van Bruggen, Jérôme Baton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Create data

Obviously, to create data, the keyword is CREATE, as we saw it earlier in our Shakespearean example:

CREATE (romeo:Person{name: "Romeo"})-[:LOVES]->(juliet:Person{name:"Juliet"})

Going from left to right in this example, a first node romeo, is created, with the label Person and one string property--name valued Romeo. Then, a relation LOVES is linking the first node to a second node, juliet.

A relation is always directed in Neo4j, so basically, we could create a second LOVES relation from juliet to romeo to model the story better, as follows:

CREATE (romeo:Person{name: "Romeo"})-[:LOVES]->(juliet:Person{name:"Juliet"})CREATE (juliet)-[:LOVES]->(romeo)RETURN romeo, juliet;

However, this is not mandatory. Not because love sometimes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required