Más contenido relacionado Similar a Neo4j Graph Data Modeling (20) Más de Kenny Bastani (13) Neo4j Graph Data Modeling5. © All Rights Reserved 2014 | Neo Technology, Inc.
Agenda
•What
96. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
(Introduction
99. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
What
103. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
Zombie Pastimes
Eating Brains
Dancing With
Michael Jackson
% of People Who Hate Michael Jackson by Date
0
25
50
75
100
June 25, 2009 June 26,2009
7
104. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
Zombie Pastimes
Eating Brains
Dancing With
Michael Jackson
% of People Who Hate Michael Jackson by Date
0
25
50
75
100
June 25, 2009 June 26,2009
These
108. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
So
112. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
John
Sally
Graph Databases
Book
Friend Of
Friend Of
H
as ReadHasRead
10
113. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
name: John
age: 27
name: Sally
age: 32
title: Graph Databases
authors: Ian Robinson,
Jim Webber
FRIEND_OF
since: 01/09/2013
HAS_READ
on: 2/03/2013
rating: 5
HAS_READ
on: 02/09/2013
rating: 4
FRIEND_OF
since: 01/09/2013
11
114. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
The
118. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
Customers AccountsCustomer_Accounts
143 Alice
326
$100
725
$632
981 $212
143 981
143 725
143 326
13
119. © All Rights Reserved 2014 | Neo Technology, Inc.
(Introduction
133. © All Rights Reserved 2014 | Neo Technology, Inc.
Nodes
16
134. © All Rights Reserved 2014 | Neo Technology, Inc.
Nodes
•Nodes
171. © All Rights Reserved 2014 | Neo Technology, Inc.
Relationships
18
172. © All Rights Reserved 2014 | Neo Technology, Inc.
Relationships
173. (continued)
19
Nodes
can
have
more
than
one
relationship
Self
relationships
are
allowed
Nodes
can
be
connected
by
more
than
one
relationship
174. © All Rights Reserved 2014 | Neo Technology, Inc.
Relationships
•Every
213. © All Rights Reserved 2014 | Neo Technology, Inc.
Labels
21
214. © All Rights Reserved 2014 | Neo Technology, Inc.
Labels
•Every
262. © All Rights Reserved 2014 | Neo Technology, Inc.
(Introduction
265. © All Rights Reserved 2014 | Neo Technology, Inc.
Cypher
287. © All Rights Reserved 2014 | Neo Technology, Inc.
(a) -- (b)
a b
Text
289. © All Rights Reserved 2014 | Neo Technology, Inc.
Either
291. © All Rights Reserved 2014 | Neo Technology, Inc.
Direction
293. © All Rights Reserved 2014 | Neo Technology, Inc.
33
b
a
b
a
b
a
MATCH (a)--(b)
RETURN a, b;
294. © All Rights Reserved 2014 | Neo Technology, Inc.
(a) -[r]- ()
a
Relationships
34
r
299. © All Rights Reserved 2014 | Neo Technology, Inc.
(a) -[:ACTED_IN]- (m)
a m
Actors
302. © All Rights Reserved 2014 | Neo Technology, Inc.
Return
314. © All Rights Reserved 2014 | Neo Technology, Inc.
Paths
39
(a)--(b)--(c)
a b c
315. © All Rights Reserved 2014 | Neo Technology, Inc.
40
b
c
a
b
c
a
b
a
(a)--(b)--(c)
316. © All Rights Reserved 2014 | Neo Technology, Inc.
Paths
41
(a)--(b)--(c)
a b c
317. © All Rights Reserved 2014 | Neo Technology, Inc.
Paths
42
(a)--(b)--(c)
a b c
318. © All Rights Reserved 2014 | Neo Technology, Inc.
43
c
b
a
c
b
c
b
a
a
(a)--(b)--(c)
332. © All Rights Reserved 2014 | Neo Technology, Inc.
45
MATCH (a)-[:ACTED_IN]-(m)-[:DIRECTED]-(d)
RETURN a.name, m.title, d.name;
d
m
a
d
m
d
m
a
a
333. © All Rights Reserved 2014 | Neo Technology, Inc.
Table
340. supported
47
count(x) - add up the number of occurrences
min(x) - get the lowest value
max(x) - get the highest value
avg(x) - get the average of a numeric value
sum(x) - add up all values
collect(x) - collected all the occurrences into an array
341. © All Rights Reserved 2014 | Neo Technology, Inc.
MATCH (a)-[:ACTED_IN]-(m)-[:DIRECTED]-(d)
RETURN a.name, d.name, count(*) AS count
ORDER BY count DESC
LIMIT 5;
Sort
351. © All Rights Reserved 2014 | Neo Technology, Inc.
Graph
361. © All Rights Reserved 2014 | Neo Technology, Inc.
All-nodes
375. © All Rights Reserved 2014 | Neo Technology, Inc.
53
MATCH (n {n.name:Tom Hanks})
RETURN n;
t
383. © All Rights Reserved 2014 | Neo Technology, Inc.
55
MATCH (tom:Person {name:Tom Hanks})
RETURN tom;
t
384. © All Rights Reserved 2014 | Neo Technology, Inc.
Start
390. © All Rights Reserved 2014 | Neo Technology, Inc.
57
m
m
m
t
m
MATCH (tom:Person {name:Tom Hanks})-[:ACTED_IN]-(movie:Movie)
RETURN movie.title;
391. © All Rights Reserved 2014 | Neo Technology, Inc.
Start
397. © All Rights Reserved 2014 | Neo Technology, Inc.
59
MATCH (tom:Person {name:Tom Hanks})-[:ACTED_IN]-(movie:Movie)
(director:Person)-[:DIRECTED]-(movie)
RETURN director.name;
t
d
d
398. © All Rights Reserved 2014 | Neo Technology, Inc.
(Tour
403. © All Rights Reserved 2014 | Neo Technology, Inc.
http://localhost:7474/
Neo4j
408. © All Rights Reserved 2014 | Neo Technology, Inc.
Neo4j
413. © All Rights Reserved 2014 | Neo Technology, Inc.
Neo4j
419. © All Rights Reserved 2014 | Neo Technology, Inc.
Neo4j
426. © All Rights Reserved 2014 | Neo Technology, Inc.
(Graph
431. © All Rights Reserved 2014 | Neo Technology, Inc.
67
MATCH (me:Person {name:’Philip’})-[:FRIEND_OF]-(friends),
(friends)-[:LIKES]-(restaurant),
(restaurant)-[:LOCATED_IN]-(city {Location = ‘New York’}),
(restaurant)-[:SERVES]-(cuisine {cuisine = ‘Sushi’})
RETURN restaurant.name
* Cypher query language example
433. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
(Introduction
437. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
Start
441. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
71
442. © 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_OF
SHARED
COMMENTED
Sarah
FUNNY
ON
LIKES
72
443. © 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_OF
SHARED
COMMENTED
Sarah
FUNNY
ON
LIKES
73
444. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
74
445. © 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 Atlas
The Matrix
Lana
Wachowski
ACTED_IN
ACTED_IN
ACTED_IN
DIRECTED
DIRECTED
75
446. © All Rights Reserved 2014 | Neo Technology, Inc.© All Rights Reserved 2013 | Neo Technology, Inc.© All Rights Reserved 2014 | Neo Technology, Inc.
Model
448. © 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 Atlas
The Matrix
Lana
Wachowski
ACTED_IN
ACTED_IN
ACTED_IN
DIRECTED
DIRECTED
77
449. © 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
78
450. © All Rights Reserved 2014 | Neo Technology, Inc.
(Graph
454. © All Rights Reserved 2014 | Neo Technology, Inc.
Symmetric
456. © All Rights Reserved 2014 | Neo Technology, Inc.
Infer
464. © All Rights Reserved 2014 | Neo Technology, Inc.
Bi-Directional
475. © All Rights Reserved 2014 | Neo Technology, Inc.
Qualified
478. © All Rights Reserved 2014 | Neo Technology, Inc.
Properties
537. © All Rights Reserved 2014 | Neo Technology, Inc.
Example:
580. © All Rights Reserved 2014 | Neo Technology, Inc.
Relationship
582. © All Rights Reserved 2014 | Neo Technology, Inc.
General
586. © All Rights Reserved 2014 | Neo Technology, Inc.
Specific
600. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
607. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
664. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
697. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
719. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
722. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
731. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
734. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
763. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
776. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
790. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
843. © All Rights Reserved 2014 | Neo Technology, Inc.
Authoring
849. © All Rights Reserved 2014 | Neo Technology, Inc.
(Thank
853. touch
Twitter:
@kennybastani
LinkedIn:
/in/kennybastani
Email:
kenny.bastani@neotechnology.com