building killer apps with neo4j 2.0

56
(graphs)-[:are]->(everywhere) Building Killer Apps with Neo4j © All Rights Reserved 2014 | Neo Technology, Inc. @kennybastani Neo4j Developer Evangelist

Upload: kenny-bastani

Post on 26-Jan-2015

122 views

Category:

Technology


1 download

DESCRIPTION

As companies like Facebook and Google have introduced us to Graph Search and the Knowledge Graph, developers are learning the benefits of graph database architectures. Graph databases, like Neo4j, have increased in popularity by nearly 250% from last year - the highest among all other DBMS categories, according to db-engines.com. Join Kenny Bastani as we look at the benefits of using a graph database, explore various use cases and walkthrough creating a movie recommendation app on Neo4j 2.0.

TRANSCRIPT

Page 1: Building Killer Apps with Neo4j 2.0

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

Building����������� ������������������  Killer����������� ������������������  Apps����������� ������������������  with����������� ������������������  Neo4j

© All Rights Reserved 2014 | Neo Technology, Inc.

@kennybastani

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

Page 2: Building Killer Apps with Neo4j 2.0

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: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2013 | Neo Technology, Inc.

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

Page 4: Building Killer Apps with Neo4j 2.0

© 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: Building Killer Apps with Neo4j 2.0

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

Page 6: Building Killer Apps with Neo4j 2.0

© 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: Building Killer Apps with Neo4j 2.0

© 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: Building Killer Apps with Neo4j 2.0

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

Page 9: Building Killer Apps with Neo4j 2.0

© 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: Building Killer Apps with Neo4j 2.0

© 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: Building Killer Apps with Neo4j 2.0

© 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: Building Killer Apps with Neo4j 2.0

© 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: Building Killer Apps with Neo4j 2.0

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

Page 14: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

http://localhost:7474/

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

14

Page 15: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

15

Page 16: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

16

Page 17: Building Killer Apps with Neo4j 2.0

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

Page 18: Building Killer Apps with Neo4j 2.0

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

Page 19: Building Killer Apps with Neo4j 2.0

Architecture

Page 20: Building Killer Apps with Neo4j 2.0

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

Page 21: Building Killer Apps with Neo4j 2.0

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

Page 22: Building Killer Apps with Neo4j 2.0

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

Page 23: Building Killer Apps with Neo4j 2.0

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

• Start with listing out the questions you want to answer

Page 24: Building Killer Apps with Neo4j 2.0

• 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: Building Killer Apps with Neo4j 2.0

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

Page 26: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

Page 27: Building Killer Apps with Neo4j 2.0

© 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: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

28

A

B C

Page 29: Building Killer Apps with Neo4j 2.0

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

Page 30: Building Killer Apps with Neo4j 2.0

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

Page 31: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

Page 32: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

(a) --> (b)

a b

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

32

Page 33: Building Killer Apps with Neo4j 2.0

© 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 34: Building Killer Apps with Neo4j 2.0

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

Page 35: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

35

Page 36: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

36

Page 37: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

37

Page 38: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

38

Page 39: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

39

Page 40: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

40

Page 41: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

41

Page 42: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

42

Page 43: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

43

Page 44: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

44

Page 45: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

45

Page 46: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

46

Page 47: Building Killer Apps with Neo4j 2.0

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

Page 48: Building Killer Apps with Neo4j 2.0

Demo

Page 49: Building Killer Apps with Neo4j 2.0

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

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

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

Page 50: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

Page 51: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

Page 52: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

Page 53: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

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

Page 54: Building Killer Apps with Neo4j 2.0

© All Rights Reserved 2014 | Neo Technology, Inc.

http://neo4j.meetup.com/

Page 55: Building Killer Apps with Neo4j 2.0

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

Page 56: Building Killer Apps with Neo4j 2.0

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

Twitter: @kennybastani

LinkedIn: /in/kennybastani