BrainPreview
Open in TheBrain

Neo4j Introductions to Cypher

<p><a href="https://neo4j.com/docs/getting-started/current/cypher-intro/">Chapter 3. Introduction to Cypher - The Neo4j Getting Started Guide v3.5</a></p>

<p>&nbsp;</p>

<p>This chapter gives a high-level overview of the graph query language Cypher.</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>Nodes go in&nbsp;( )</p>

<pre class="programlisting highlight"><code class=" cm-s-neo" data-lang="cypher"><span class="cm-node">(</span><span class="cm-node">)</span>

<span class="cm-node">(</span><span class="cm-variable">matrix</span><span class="cm-node">)</span>

<span class="cm-node">(</span><span class="cm-variable">:Movie</span><span class="cm-node">)</span>

<span class="cm-node">(</span><span class="cm-atom">matrix:Movie</span><span class="cm-node">)</span>

<span class="cm-node">(</span><span class="cm-atom">matrix:Movie</span> <span class="cm-node">{</span><span class="cm-atom">title:</span> <span class="cm-string">"The Matrix"</span><span class="cm-node">}</span><span class="cm-node">)</span>

<span class="cm-node">(</span><span class="cm-atom">matrix:Movie</span> <span class="cm-node">{</span><span class="cm-atom">title:</span> <span class="cm-string">"The Matrix"</span><span class="cm-node">,</span> <span class="cm-atom">released:</span> <span class="cm-variable">1997</span><span class="cm-node">}</span><span class="cm-node">)</span></code></pre>

<p>&nbsp;</p>

<p>The simplest form,<span style="color: #ff0000;">&nbsp;<code class="literal">()</code></span>, represents an anonymous, uncharacterized node.</p>

<p>If we want to refer to the node elsewhere, we can add a variable, for example:&nbsp;<span style="color: #ff0000;"><code class="literal">(matrix)</code></span>. A variable is restricted to a single statement. It may have different or no meaning in another statement.</p>

<p>&nbsp;</p>

<p> A variable is restricted to a single statement. It may have different or no meaning in another statement.</p>

<p>The&nbsp;<span style="color: #ff0000;"><code class="literal">:Movie</code></span> pattern declares a label of the node. This allows us to restricts the pattern, keeping it from matching (say) a structure with an&nbsp;<span style="color: #ff0000;"><code class="literal">Actor</code></span> node in this position.</p>

<p>The node&rsquo;s properties, for example&nbsp;<span style="color: #ff0000;"><code class="literal">title</code></span>, are represented as a list of key/value pairs, enclosed within a pair of braces, for example:&nbsp;<span style="color: #ff0000;"><code class="literal">{name: "Keanu Reeves"}</code></span>. Properties can be used to store information and/or restrict patterns.</p>