16. His friends introduced more friends
๏ Michael: master hacker
Michael Peter Emil
Andreas
Kerstin
17. His friends introduced more friends
๏ Michael: master hacker
๏ Johan: technology sage
Michael Johan
Peter Emil
Andreas
Kerstin
18. His friends introduced more friends
๏ Michael: master hacker
๏ Johan: technology sage
๏ Madelene: polyglot journalist
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
19. His friends introduced more friends
๏ Michael: master hacker
๏ Johan: technology sage
๏ Madelene: polyglot journalist
๏ Allison: marketing maven
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
20. So, we have a bunch of people
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
21. So, we have a bunch of people
๏ how do we know they are friends?
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
22. So, we have a bunch of people
๏ how do we know they are friends?
๏ either ask each pair: are you friends?
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
23. So, we have a bunch of people
๏ how do we know they are friends?
๏ either ask each pair: are you friends?
๏ or, we can add explicit connections
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
24. So, we have a bunch of people
๏ how do we know they are friends?
๏ either ask each pair: are you friends?
๏ or, we can add explicit connections
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
25. There's a problem here
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
26. There's a problem here
๏ Emil is awesome
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
27. There's a problem here
๏ Emil is awesome
๏ What about other relationships?
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
28. There's a problem here
๏ Emil is awesome
๏ What about other relationships?
๏ We mentioned "introductions" so there must've
been at least some pre-existing connections
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
29. There's a problem here
๏ Emil is awesome
๏ What about other relationships?
๏ We mentioned "introductions" so there must've
been at least some pre-existing connections
Allison
Michael Johan
Peter Emil
Andreas
Madelene Kerstin
31. This can continue...
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
32. This can continue...
๏ this is how social networks grow
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
33. This can continue...
๏ this is how social networks grow
๏ either meet people directly
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
34. This can continue...
๏ this is how social networks grow
๏ either meet people directly
๏ or be introduced
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
35. This can be useful
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
36. This can be useful
๏ professional recommendation (LinkedIn)
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
37. This can be useful
๏ professional recommendation (LinkedIn)
๏ product recommendation (Amazon)
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
38. This can be useful
๏ professional recommendation (LinkedIn)
๏ product recommendation (Amazon)
๏ restaurant recommendations (Yelp)
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
39. This can be useful
๏ professional recommendation (LinkedIn)
๏ product recommendation (Amazon)
๏ restaurant recommendations (Yelp)
๏ same domain, or reaching across domains
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
40. This is really just data
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
41. This is really just data
๏ it's just a graph
Allison
Michael Johan
Peter Emil
Anna
Andreas Adam
Madelene Kerstin
46. Yes, a graph...
๏ you know the common data structures
•linked lists, trees, object "graphs"
13
47. Yes, a graph...
๏ you know the common data structures
•linked lists, trees, object "graphs"
๏ a graph is the general purpose data structure
13
48. Yes, a graph...
๏ you know the common data structures
•linked lists, trees, object "graphs"
๏ a graph is the general purpose data structure
•suitable for any connected data
13
49. Yes, a graph...
๏ you know the common data structures
•linked lists, trees, object "graphs"
๏ a graph is the general purpose data structure
•suitable for any connected data
๏ well-understood patterns and algorithms
13
50. Yes, a graph...
๏ you know the common data structures
•linked lists, trees, object "graphs"
๏ a graph is the general purpose data structure
•suitable for any connected data
๏ well-understood patterns and algorithms
•studied since Leonard Euler's 7 Bridges (1736)
13
51. Yes, a graph...
๏ you know the common data structures
•linked lists, trees, object "graphs"
๏ a graph is the general purpose data structure
•suitable for any connected data
๏ well-understood patterns and algorithms
•studied since Leonard Euler's 7 Bridges (1736)
•Codd's Relational Model (1970)
13
52. Yes, a graph...
๏ you know the common data structures
•linked lists, trees, object "graphs"
๏ a graph is the general purpose data structure
•suitable for any connected data
๏ well-understood patterns and algorithms
•studied since Leonard Euler's 7 Bridges (1736)
•Codd's Relational Model (1970)
•not a new idea, just an idea who's time is now
13
85. A graph database...
๏ optimized for the connections between records
๏ really, really fast at querying across records
19
86. A graph database...
๏ optimized for the connections between records
๏ really, really fast at querying across records
๏ a database: transactional with the usual
operations
19
87. A graph database...
๏ optimized for the connections between records
๏ really, really fast at querying across records
๏ a database: transactional with the usual
operations
๏ “A relational database may tell you
the average age of everyone at this workshop,
but a graph database will tell you
who is most likely to buy you a beer.”
19
108. We're talking about a
Property Graph
Em Joh
il a n
knows knows
Alli Tob Lar
Nodes
son ias knows s
knows
And And knows
knows rea rés
s
knows knows knows
Pet Miic
Mc knows Ian
er knows a
a
knows knows
De Mic
lia h ael
Relationships
Properties (each a key+value)
+ Indexes (for easy look-ups)
21
113. Cypher - a graph query language
๏ a pattern-matching query language
๏ declarative grammar with clauses (like SQL)
๏ aggregation, ordering, limits
๏ create, read, update, delete
23
114. Cypher - a graph query language
๏ a pattern-matching query language
๏ declarative grammar with clauses (like SQL)
๏ aggregation, ordering, limits
๏ create, read, update, delete
// get node 1, traverse 2 steps away
start a=node(1) match (a)--()--(c) return c
// create a node with a 'name' property
CREATE (me {name: 'Andreas'}) return me
๏ more on this later...
23
143. Cypher - read clauses
// get node 1, traverse 2 steps away
START a=node(1) MATCH (a)--()--(c) RETURN c
// get node from an index, return it
START a=node:users(login='akollegger')
RETURN a
// get node from an index, match, filter
// with where, then return results
START a=node:users(login='akollegger')
MATCH (a)-[r]-(b) WHERE b.login='jakewins'
RETURN r,b
31
149. Cypher - CREATE relationships
LOVES
A B
A -[:LOVES]-> B
// create love between two people
START a=node:people(name='Andreas'),
b=node:people(name='Anna')
CREATE a-[:LOVES]->(b)
33
153. Cypher - CREATE UNIQUE data
LOVES
A B
A -[:LOVES]-> B
// create love between two people
START a=node:people(name='Andreas'),
b=node:people(name='Anna')
CREATE UNIQUE a-[:LOVES]->(b)
34
157. Cypher - CREATE full path
LOVES
A B
A -[:LOVES]-> B
// create an entire path at once
CREATE p=(a {name:'Andreas'})-[:LOVES]->
(b {name:'Anna'}) return p
35
163. Cypher - DELETE data
LOVES
A B
A -[:LOVES]-> B
// Goodbye Anna! remove relationships
START a=node:people(name='Anna')
MATCH a-[r]-(b)
DELETE a,r
37
165. Github - collaborative coding
๏ Hosting of git repositories
๏ Prominent social aspect
• follow other coders
• collaborate with other coders
• branches and forks
• watch repositories
• star repositories
39
169. Github User Graph - complete
heroku
member of
neo4j mattt
follows
member of
akollegger follows jakewins
owns
follows follows
FEC_GRAPH nawroth
follows
collaborates on
jexp
details: http://developer.github.com 41
170. Github User Graph - complete
heroku
member of
neo4j mattt
follows
member of
akollegger follows jakewins
owns
follows follows
FEC_GRAPH nawroth
follows
collaborates on
jexp
details: http://developer.github.com 41
171. Github User Graph - complete
heroku
member of
(user)-[:follows]->(users) neo4j mattt
follows
member of
akollegger follows jakewins
owns
follows follows
FEC_GRAPH nawroth
follows
collaborates on
jexp
details: http://developer.github.com 41
172. Github User Graph - complete
heroku
member of
(user)-[:follows]->(users) neo4j mattt
(user)-[:member_of]->(org)
follows
member of
akollegger follows jakewins
owns
follows follows
FEC_GRAPH nawroth
follows
collaborates on
jexp
details: http://developer.github.com 41
173. Github User Graph - complete
heroku
member of
(user)-[:follows]->(users) neo4j mattt
(user)-[:member_of]->(org)
(user)-[:owns]->(repository) member of
follows
akollegger follows jakewins
owns
follows follows
FEC_GRAPH nawroth
follows
collaborates on
jexp
details: http://developer.github.com 41
174. Github User Graph - complete
heroku
member of
(user)-[:follows]->(users) neo4j mattt
(user)-[:member_of]->(org)
(user)-[:owns]->(repository) member of
follows
(user)-[:collaborates_on]->(repos)
akollegger follows jakewins
owns
follows follows
FEC_GRAPH nawroth
follows
collaborates on
jexp
details: http://developer.github.com 41