Database Reference
In-Depth Information
Create
CREATE is analogous to an INSERT statement in SQL. Listing 2-1 is a very basic example of a CREATE operation.
Listing 2-1. Example CREATE query statement
CREATE (n:Business { name : 'GraphStory', description : 'Graph as a Service' })
Start
In the latest version of Neo4j, the START clause has become an optional part of a read operation. The counterparts in
SQL are portions of the FROM and WHERE clauses. In Listing 2-2, the lowercase business represents the variable being
returned, which is closer to the SELECT clause in SQL, but in this case the business variable also returns all of the
properties (or columns , as they are referred to in a relational database). The Business index is equivalent to a table in
the relational database world, and the name='GraphStory' portion is similar to a WHERE clause.
Listing 2-2. Example START query statement on the index Business
START business=node:Business (name = 'GraphStory')
RETURN business
Match
A MATCH clause represents a similar operation as a JOIN would in SQL. The Cypher statement in Listing 2-3 displays
how to return a collection of people who like GraphStory.
Listing 2-3. Sample MATCH query statement in earlier versions of Neo4j
START business=node:Business (name = 'GraphStory')
MATCH people-[:LIKE]->business
RETURN people
A shorter way to represent the same result is to use Label , which excludes the START clause. The example shown
in Listing 2-4 is the current recommended way of executing a MATCH result.
Listing 2-4. The recommended way to execute a MATCH query statement
MATCH person-[:LIKE]->(b:Business { name: "Graph Story"})
RETURN person
 
Search WWH ::




Custom Search