The fundamental concepts

A graph database stores data using the concepts below:

  1. Nodes – graph data records

  2. Relationships – connect nodes

  3. Properties – named data values

The simplest graph is a graph with just a single node with some properties.

  • Properties are simply name/value pairs

  • Nodes can be grouped together using labels. For example, you could group all the people’s nodes under the label Person. A node can have zero or more labels

  • Labels do not have any properties

Relationships

  • The real power of graph database is in the connected data. We use relationships to associate any two nodes, describing how the nodes are related to each other

  • Relationships always have direction

  • Relationships always have a type

  • Relationships form patterns of data

  • Relationships CAN have properties

An example is Emil KNOWS Johan. In this instance, Emil and Johan are two Person nodes connected by the relationship KNOWS.

What is Cypher?

Cypher is the Neo4j’s graph query language for working with graph data. It has similar SQL-like clauses and it uses patterns to describe graph data.

Below are few basic commands:
  1. CREATE – to create data

  2. MATCH – specify a pattern of nodes and relationships

  3. WHERE – set constraints to the results

  4. RETURN – request particular results

  5. DISTINCT – return unique results

  6. PROFILE or EXPLAIN – understand how your query works

  7. Use () parenthesis to indicate a node

  8. Use [] to indicate relationships

Cypher can be used for pattern matching, recommendation, and analysis.

Ryan

Ryan

Data Scientist

Leave a Reply