Introduction to Neo4j

We could talk about the history and theory of graph databases, or we can dive in to the most popular graph database around. Let’s do the latter.

Getting Started

It’s easy to start. Just:

Review of the Fundamentals

Quick check. Did you remember these facts about graph databases in general?

The Neo4j browser allows you to type in queries and see the results as pictures or tables. The query language is called Cypher. Here are the first few Cypher queries from the tutorial. Remember what they did?

CREATE (ee:Person { name: "Emil", from: "Sweden", klout: 99 })
MATCH (ee:Person) WHERE ee.name = "Emil" RETURN ee;
CREATE (js:Person { name: "Johan", from: "Sweden", learn: "surfing" }),
    (ir:Person { name: "Ian", from: "England", title: "author" }),
    (rvb:Person { name: "Rik", from: "Belgium", pet: "Orval" }),
    (ally:Person { name: "Allison", from: "California", hobby: "surfing" }),
    (ee)-[:KNOWS {since: 2001}]->(js),
    (ee)-[:KNOWS {rating: 5}]->(ir),
    (js)-[:KNOWS]->(ir),
    (js)-[:KNOWS]->(rvb),
    (ir)-[:KNOWS]->(js),
    (ir)-[:KNOWS]->(ally),
    (rvb)-[:KNOWS]->(ally)
MATCH (ee:Person)-[:KNOWS]-(friends)
WHERE ee.name = "Emil" RETURN ee, friends
MATCH (js:Person)-[:KNOWS]-()-[:KNOWS]-(surfer)
WHERE js.name = "Johan" AND surfer.hobby = "surfing"
RETURN DISTINCT surfer

Cypher Basics

Cypher is a declarative language in which you write patterns. Variables in the patterns “retrieve” data when matched against your data graph.

. . . .

Why is Neo Cool?