building killer apps with neo4j 2.0

Post on 26-Jan-2015

117 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

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

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

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

© All Rights Reserved 2014 | Neo Technology, Inc.

@kennybastani

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

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

© All Rights Reserved 2013 | Neo Technology, Inc.

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

© 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

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

© 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

© 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

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

© 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

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

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

© 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

© 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

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

© All Rights Reserved 2014 | Neo Technology, Inc.

http://localhost:7474/

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

14

© All Rights Reserved 2014 | Neo Technology, Inc.

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

15

© All Rights Reserved 2014 | Neo Technology, Inc.

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

16

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

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

Architecture

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

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

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

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

• Start with listing out the questions you want to answer

• 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

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

© All Rights Reserved 2014 | Neo Technology, Inc.

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

© 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

© All Rights Reserved 2014 | Neo Technology, Inc.

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

28

A

B C

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

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

© All Rights Reserved 2014 | Neo Technology, Inc.

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

© All Rights Reserved 2014 | Neo Technology, Inc.

(a) --> (b)

a b

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

32

© 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

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

© All Rights Reserved 2014 | Neo Technology, Inc.

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

35

© All Rights Reserved 2014 | Neo Technology, Inc.

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

36

© All Rights Reserved 2014 | Neo Technology, Inc.

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

37

© All Rights Reserved 2014 | Neo Technology, Inc.

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

38

© All Rights Reserved 2014 | Neo Technology, Inc.

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

39

© All Rights Reserved 2014 | Neo Technology, Inc.

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

40

© All Rights Reserved 2014 | Neo Technology, Inc.

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

41

© All Rights Reserved 2014 | Neo Technology, Inc.

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

42

© All Rights Reserved 2014 | Neo Technology, Inc.

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

43

© All Rights Reserved 2014 | Neo Technology, Inc.

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

44

© All Rights Reserved 2014 | Neo Technology, Inc.

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

45

© All Rights Reserved 2014 | Neo Technology, Inc.

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

46

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

Demo

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

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

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

© All Rights Reserved 2014 | Neo Technology, Inc.

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

© All Rights Reserved 2014 | Neo Technology, Inc.

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

© All Rights Reserved 2014 | Neo Technology, Inc.

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

© All Rights Reserved 2014 | Neo Technology, Inc.

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

© All Rights Reserved 2014 | Neo Technology, Inc.

http://neo4j.meetup.com/

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

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

Twitter: @kennybastani

LinkedIn: /in/kennybastani

top related