We live in a connected world. There are no isolated pieces of information, but rich, connected domains all around us.

What Is a Graph?

  • Formally, a graph is just a collection of vertices and edges.
  • In less intimidating language, a set of nodes and the relationships that connect them.
  • Graphs represent entities.

Neo4j

  • Sponsored by Neo Technology, Neo4j is an open-source NoSQL graph database implemented in Java and Scala.
  • Development started in 2003, it has been publicly available since 2007. The source code and issue tracking are available on GitHub.
  • Neo4j is used today by hundreds of thousands of companies and organizations in almost all industries. Use cases include matchmaking, network management, software analytics, scientific research, routing, organizational and project management, recommendations, social networks, and more.

Neo4j

  • Neo4j implements the Property Graph Model efficiently down to the storage level.
  • As opposed to graph processing or in-memory libraries, Neo4j provides full database characteristics including ACID transaction compliance, cluster support, and runtime failover, making it suitable to use graph data in production scenarios.

The Labeled Property Graph Model

• It contains nodes and relationships.
• Nodes contain properties (key-value pairs).
• Nodes can be labeled with one or more labels.
• Relationships are named and directed, and always have a start and end node.
• Relationships can also contain properties.

Northwind

Graph Model

Cypher

It consists of clauses, keywords and expressions like predicates and functions

WHEREORDER BYSKIP LIMITANDp.unitPrice > 10

As Cypher is all about expressing patterns

circles of nodes are represented with round parentheses, like this: (p:Product)

And arrows of relationships are drawn as such -->

you can add the relationship-type in square brackets
-[:ORDERED]->

()-->()<--()

(cust:Customer)-[:ISSUED]->(o:Order)-[:CONTAINS]->(prod:Product)
SELECT p.*
FROM products as p;
MATCH (p:Product)
RETURN p;
SELECT p.ProductName, p.UnitPrice
FROM products as p
ORDER BY p.UnitPrice DESC
LIMIT 10;
MATCH (p:Product)
RETURN p.productName, p.unitPrice
ORDER BY p.unitPrice DESC
LIMIT 10;
MATCH (p:Product)
WHERE p.productName = "Chocolade"
RETURN p.productName, p.unitPrice;
SELECT p.ProductName, p.UnitPrice
FROM products as p
WHERE p.ProductName = 'Chocolade';
SELECT distinct c.CompanyName
FROM customers AS c
JOIN orders AS o ON (c.CustomerID = o.CustomerID)
JOIN order_details AS od ON (o.OrderID = od.OrderID)
JOIN products as p ON (od.ProductID = p.ProductID)
WHERE p.ProductName = 'Chocolade';
MATCH (p:Product {productName:"Chocolade"})<-[:PRODUCT]-(:Order)<-[:PURCHASED]-(c:Customer)
RETURN distinct c.companyName;

Community Edition

Running...

GOT Neo4j

Sample Data

Find all children of all houses

Tully, Baratheon, Lannister, Stark, Targaryen

Find all the children of parents that are siblings

a.k.a incest

Demo

What is a GraphGist?

  • A way to share documents including Cypher queries
  • The queries can be executed in an on-line console
  • Can be used to share examples or ideas or outline a question you have

Gist Demos

Infrastructure Demo

C#?

:play movies

neo4j

By divan

neo4j

  • 688