Research · Technique

Practical Neo4j note

Book: Practical Neo4j – Gregory Jordan

Contents:

  1. Introduction to graphs
  2. Running with Neo4j
  3. Modeling
  4. Querying
  5. Importing from external data
  6. Extending Neo4j
  7. Neo4j + Python

1. Introduction to graphs

  • A graph database is a set of vertices and edges. Vertices are referred to as nodes and edges are referred to as relationships.
  • The concept of labels was introduced as a way to group nodes.
  • Traversal is the most common method for querying a graph which begins with a single node that follows a path of relationships over connected nodes.
  • Indexes for a specific node or relationship.
  • Relational Databases vs Neo4j:
    • Data affiliation does not have to be exclusive.
    • The limitation on how a relationship is defined within a relational database is one reason to consider switching to a graph database.
    • Avoid the half-measures and workarounds that your model fits within in a relational database.
    • Avoid what might be referred to as “join hell”.
    • Both can achieve what is known as ACID compliance (ACID – Atomicity, Consistency, Isolation and Durability).
  • NoSQL vs Neo4j
    • NoSQL: key-value, column-family, document and graph databases.

2. Running with Neo4j

Neo4j

  • Install easy
  • Neo4j brower: http://localhost:7474.

Cypher

  • Create: = Insert in SQL.

CREATE (node:Business{name: ‘GraphStory’, description: ‘Graph as a Service’})

  • Start: closer to the SELECT in SQL.

START business=node:Business(name=’GraphStory’)

RETURN business

  • Match: similar to JOIN in SQL.

START business = node:Business (name=’GraphStory’)

MATCH people-[:LIKE] -> business

RETURN people

 

MATCH person-[:LIKE]->(b:Business{name:”Graph Story”})

RETURN person

  • SET: similar to UPDATE in SQL.

MATCH (b:Business {name:’GraphStory’})

SET b.description = ‘The leading graph database as a service provider’

RETURN b

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s