Transcript
Page 1: Neo4j Makes Graphs Easy

(graphs)-[:are]->(everywhere)

Neo4j����������� ������������������  Makes����������� ������������������  Graphs����������� ������������������  Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

@kennybastani

Neo4j����������� ������������������  Developer����������� ������������������  Evangelist

Page 2: Neo4j Makes Graphs Easy

Agenda

• An Introduction to Graph-based Modeling

• A Tour of Neo4j’s Browser

• How to Build Graph-based Web App for Movies

• How to Design a Graph-based Neo4j REST API

• An Introduction to Cypher (Neo4j’s Query Language)

• How to Translate Questions Into Cypher Queries

Page 3: Neo4j Makes Graphs Easy

© All Rights Reserved 2013 | Neo Technology, Inc.

Introduction����������� ������������������  to����������� ������������������  Graph-based����������� ������������������  modeling

Page 4: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.

Start����������� ������������������  with����������� ������������������  a����������� ������������������  whiteboard

Page 5: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.5

Page 6: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.

Adam

LOL Cat

FRIEND_OFSHARED

COMMENTED

SarahFUNNY

ON

LIKES

6

Page 7: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.

Adam

LOL Cat

FRIEND_OFSHARED

COMMENTED

SarahFUNNY

ON

LIKES

7

Page 8: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.8

Page 9: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.

Tom Hanks Hugo Weaving

Cloud AtlasThe Matrix

Lana Wachowski

ACTED_IN

ACTED_INACTED_IN

DIRECTED

DIRECTED9

Page 10: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.

Model����������� ������������������  Incrementally

Page 11: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.

Tom Hanks Hugo Weaving

Cloud AtlasThe Matrix

Lana Wachowski

ACTED_IN

ACTED_INACTED_IN

DIRECTED

DIRECTED11

Page 12: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.

name: Tom Hanks nationality: USA won: Oscar, Emmy

name: Hugo Weaving nationality: Australia won: MTV Movie Award

title: Cloud Atlas genre: drama, sci-fi

title: The Matrix genre: sci-fi

name: Lana Wachowski nationality: USA won: Razzie, Hugo

ACTED_IN role: Zachry

ACTED_IN role: Bill Smoke

DIRECTED

DIRECTED

ACTED_IN role: Agent Smith

12

Page 13: Neo4j Makes Graphs Easy

Tour����������� ������������������  of����������� ������������������  Neo4j

Page 14: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

http://localhost:7474/

Neo4j����������� ������������������  Browser����������� ������������������  -����������� ������������������  finding����������� ������������������  help

14

Page 15: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Neo4j����������� ������������������  Browser����������� ������������������  Execute����������� ������������������  Cypher,����������� ������������������  Visualize

15

Page 16: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Neo4j����������� ������������������  Browser����������� ������������������  -����������� ������������������  importing����������� ������������������  sample����������� ������������������  data

16

Page 17: Neo4j Makes Graphs Easy

Neo4j����������� ������������������  Data����������� ������������������  browser����������� ������������������  -����������� ������������������  display����������� ������������������  more����������� ������������������  data

Page 18: Neo4j Makes Graphs Easy

Movies����������� ������������������  Sample����������� ������������������  App

Page 19: Neo4j Makes Graphs Easy

Architecture

Page 20: Neo4j Makes Graphs Easy

Neo4j����������� ������������������  Backend

Page 21: Neo4j Makes Graphs Easy

Swagger����������� ������������������  REST����������� ������������������  API

Page 22: Neo4j Makes Graphs Easy

Angular����������� ������������������  Front-end

Page 23: Neo4j Makes Graphs Easy

Designing����������� ������������������  a����������� ������������������  REST����������� ������������������  API

• Start with listing out the questions you want to answer

Page 24: Neo4j Makes Graphs Easy

• Get all the movies and their genre

• Get a movie an its properties

• Get actors who acted in a movie

• Get an actor and their properties

• Recommend similar movies

• Recommend similar actors

Page 25: Neo4j Makes Graphs Easy

Answering����������� ������������������  your����������� ������������������  questions����������� ������������������  using����������� ������������������  Cypher

Page 26: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Introduction����������� ������������������  to����������� ������������������  Cypher

Page 27: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Cypher����������� ������������������  is����������� ������������������  Neo4j's����������� ������������������  graph����������� ������������������  query����������� ������������������  language����������� ������������������  

•Declarative����������� ������������������  Pattern-Matching����������� ������������������  language����������� ������������������  •SQL-like����������� ������������������  syntax����������� ������������������  •Designed����������� ������������������  for����������� ������������������  graphs

27

Page 28: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

It’s����������� ������������������  all����������� ������������������  about����������� ������������������  Patterns

28

A

B C

Page 29: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.29

Page 30: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.30

Page 31: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.30

Page 32: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

How?����������� ������������������  

Page 33: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

a b

Text����������� ������������������  Art

32

Page 34: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

(a) --> (b)

a b

Text����������� ������������������  Art

32

Page 35: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Paths

33

MATCH (a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d) RETURN a.name, m.title, d.name;

a

mACTED IN

d

DIRECTED

Page 36: Neo4j Makes Graphs Easy

Translating����������� ������������������  Questions����������� ������������������  Into����������� ������������������  Cypher

Page 37: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  all����������� ������������������  movies����������� ������������������  and����������� ������������������  their����������� ������������������  genre

35

Page 38: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  all����������� ������������������  movies����������� ������������������  and����������� ������������������  their����������� ������������������  genre

36

Page 39: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  a����������� ������������������  single����������� ������������������  movie

37

Page 40: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  a����������� ������������������  single����������� ������������������  movie

38

Page 41: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  actors����������� ������������������  who����������� ������������������  acted����������� ������������������  in����������� ������������������  a����������� ������������������  movie

39

Page 42: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  actors����������� ������������������  who����������� ������������������  acted����������� ������������������  in����������� ������������������  a����������� ������������������  movie

40

Page 43: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  a����������� ������������������  single����������� ������������������  actor

41

Page 44: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  a����������� ������������������  single����������� ������������������  actor

42

Page 45: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  similar����������� ������������������  movies����������� ������������������  by����������� ������������������  shared����������� ������������������  keywords

43

Page 46: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  similar����������� ������������������  movies����������� ������������������  by����������� ������������������  shared����������� ������������������  keywords

44

Page 47: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  similar����������� ������������������  actors����������� ������������������  by����������� ������������������  co-appearance

45

Page 48: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  similar����������� ������������������  actors����������� ������������������  by����������� ������������������  co-appearance

46

Page 49: Neo4j Makes Graphs Easy

Building����������� ������������������  the����������� ������������������  Neo4j����������� ������������������  Swagger����������� ������������������  REST����������� ������������������  API

Page 50: Neo4j Makes Graphs Easy

Demo

Page 51: Neo4j Makes Graphs Easy

GitHub����������� ������������������  Repositories

• https://github.com/kbastani/node-neo4j-swagger-api

• https://github.com/kbastani/neo4j-app-movies-ui

Page 52: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

Get����������� ������������������  involved����������� ������������������  in����������� ������������������  the����������� ������������������  community

Page 53: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

http://stackoverflow.com/questions/tagged/neo4j

Page 54: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

http://groups.google.com/group/neo4j

Page 55: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

https://github.com/neo4j/neo4j/issues

Page 56: Neo4j Makes Graphs Easy

© All Rights Reserved 2014 | Neo Technology, Inc.

http://neo4j.meetup.com/

Page 57: Neo4j Makes Graphs Easy

(Thank����������� ������������������  You)

Page 58: Neo4j Makes Graphs Easy

Get����������� ������������������  in����������� ������������������  touch

Twitter: @kennybastani

LinkedIn: /in/kennybastani


Top Related