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

Writing the Cypher syntax

I like short examples to set the mind in a good direction, so I'll start with this. If I want to write Romeo loves Juliet in Cypher, the Cypher syntax will be as follows:

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

See, this is almost ASCII-Art. Do you see the pattern?

(NODE1)-[:RELATION]->(NODE2)

Now, should you want to create those nodes and relations in your database, type the following in the prompt in the upper part of the Neo4j browser (available at localhost:7474 if you have started your server):

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

Then, you are greeted with a message telling you about counts of created nodes and relations.

There you are; ...

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