Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Case Study: Real-time Recommendations with a Graph Database

5,937 views

Published on

Whether you want to be Facebook or are selling shoelaces online, if you have users then you have a social graph. Reveal the hidden graph in your data by storing key elements in a graph database, focusing on the relationships between records rather than the aggregation of records. We will look at how a large European social network added real-time recommendations to their service with a hybrid of MySQL and Neo4j, covering:

Graph concepts refresher: whiteboard friendly modeling
Polyglot persistence: storing the right data in the right place
Graph algorithms: recommendations for any domain

Published in: Technology

Case Study: Real-time Recommendations with a Graph Database

  1. 1. Realtime Recommendations with a Graph Database Andreas Kollegger #neo4j @akolleggerWednesday, August 24, 11
  2. 2. What’s the plan? ๏Graph Database 101 ๏Case Study: Viadeo ๏Finding new Friends ๏Recommending new Sites 2 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  3. 3. 3 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  4. 4. Obey! 3 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  5. 5. Obey! ๏tweet using #neo4j 3 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  6. 6. Obey! ๏tweet using #neo4j ๏I am @akollegger 3 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  7. 7. NOSQL Categories Size Data Complexity 4Wednesday, August 24, 11
  8. 8. NOSQL Categories Key-Value Store Size Data Complexity 4Wednesday, August 24, 11
  9. 9. NOSQL Categories Key-Value Store Size BigTable Clones Data Complexity 4Wednesday, August 24, 11
  10. 10. NOSQL Categories Key-Value Store Size BigTable Clones Document Databases Data Complexity 4Wednesday, August 24, 11
  11. 11. NOSQL Categories Key-Value Store Size BigTable Clones Document Databases Graph Databases Data Complexity 4Wednesday, August 24, 11
  12. 12. NOSQL Categories Key-Value Store Size BigTable Clones Document Databases Graph Databases Data Complexity 4Wednesday, August 24, 11
  13. 13. NOSQL Categories Key-Value Store (this is still billions Size BigTable of nodes & Clones relationships) Document Databases Graph 90% Databases of use cases Data Complexity 4Wednesday, August 24, 11
  14. 14. Graph DB 101 (Reading a graph) 5 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  15. 15. A graph database? 6 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  16. 16. A graph database? ๏ no: not for storing charts & graphs, or vector artwork 6 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  17. 17. A graph database? ๏ no: not for storing charts & graphs, or vector artwork ๏ yes: for storing data that is structured as a graph 6 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  18. 18. A graph database? ๏ no: not for storing charts & graphs, or vector artwork ๏ yes: for storing data that is structured as a graph • remember linked-list, tree? 6 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  19. 19. A graph database? ๏ no: not for storing charts & graphs, or vector artwork ๏ yes: for storing data that is structured as a graph • remember linked-list, tree? • graphs are the generalized connected data structure 6 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  20. 20. A graph database? ๏ no: not for storing charts & graphs, or vector artwork ๏ yes: for storing data that is structured as a graph • remember linked-list, tree? • graphs are the generalized connected data structure ๏ whiteboard friendly - no data mangling required 6 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  21. 21. A graph database? ๏ no: not for storing charts & graphs, or vector artwork ๏ yes: for storing data that is structured as a graph • remember linked-list, tree? • graphs are the generalized connected data structure ๏ whiteboard friendly - no data mangling required ๏ “A traditional relational database may tell you the average salary of everyone in this conference, but a graph database will tell you who is most likely to buy you a beer.” 6 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  22. 22. Q: What are graphs good for? 7 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  23. 23. Q: What are graphs good for? A: highly-connected data ๏ Recommendations ๏ Time series data ๏ Business intelligence ๏ Product catalogue ๏ Social computing ๏ Web analytics ๏ Geospatial ๏ Scientific computing (especially bioinformatics) ๏ MDM ๏ Systems management ๏ Indexing your slow RDBMS ๏ Genealogy ๏ And much more! 7 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  24. 24. G=(V,E) ๏ A (Graph) -records data in- (Nodes) Graph ๏ A (Graph) -records data in- (Relationships) records data in records data in organized by ๏ (Nodes) are -organized by- (Relationships) Nodes Relationships have have ๏ (Nodes & Relationships) -have- (Properties) Properties ๏ Instead of a Data Model, you have a Data Graph ๏ Structure is defined by the Relationships you create 8 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  25. 25. Query a graph with a traversal ๏ A (Traversal) -navigates- a (Graph) Traversal identifies navigates ๏ A (Traversal) -identifies- (Paths) Paths Graph ๏ (Paths) -order- (Nodes) records data in records data in order organized by Nodes Relationships ๏ Traversals reveal localized data ๏ Find data that is relevant to other data 9 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  26. 26. Indexes look-up Nodes or Relationships ๏ An (Index) -maps to either- Index special Traversal (Nodes or Relationships) maps to either maps to either ๏ An (Index) is a -special- (Traversal) organized by Nodes Relationships maps from have have ๏ Indexes find starting points for a traversal Properties ๏ Can be queried with simple constraints 10 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  27. 27. Neo4j is a Graph Database ๏ A (Graph Database) -manages- Graph Database a (Graph) and related (Indexes) manages manages ๏ A Graph Database: lookup Graph Indexes • Full ACID Transactions • High-Availability (read scaling) • 32 Billion Nodes, 32 Billion Relationships, 64 Billion Properties • Server with REST API • Or, Embeddable as a Java Library 11 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  28. 28. Neo4j Features ๏ Neo4j is stable • In 24/7 operation since 2003 ๏ Neo4j is under active development • open source, with a vibrant community ๏ High performance graph operations • high performance? like what? ... 12 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  29. 29. Example: Social Network “path exists” ๏ ~1,000 persons Madeline ๏ average 50 friends per person Andreas Emil Joanne ๏ pathExists(a,b) limited to depth 4 Gabriella Marcus Peter ๏ caches warmed up to eliminate disk I/O Jacob # persons query time Relational database 1,000 2000ms Neo4j 1,000 2ms Neo4j 1,000,000 2ms 13 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  30. 30. Example: Social Network “path exists” ๏ ~1,000 persons Madeline ๏ average 50 friends per person Andreas Emil Joanne ๏ pathExists(a,b) limited to depth 4 Gabriella Marcus Peter ๏ caches warmed up to eliminate disk I/O Jacob # persons query time Relational database 1,000 2000ms Neo4j 1,000 2ms Neo4j 1,000,000 2ms 13 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  31. 31. Example: Social Network “path exists” ๏ ~1,000 persons Madeline ๏ average 50 friends per person Andreas Emil Joanne ๏ pathExists(a,b) limited to depth 4 Gabriella Marcus Peter ๏ caches warmed up to eliminate disk I/O Jacob # persons query time Relational database 1,000 2000ms Neo4j 1,000 2ms Neo4j 1,000,000 2ms 13 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  32. 32. Example: Social Network “path exists” ๏ ~1,000 persons Madeline ๏ average 50 friends per person Andreas Emil Joanne ๏ pathExists(a,b) limited to depth 4 Gabriella Marcus Peter ๏ caches warmed up to eliminate disk I/O Jacob # persons query time Relational database 1,000 2000ms Neo4j 1,000 2ms Neo4j 1,000,000 2ms 13 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  33. 33. Case Study: Viadeo 14 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  34. 34. Case Study: Viadeo ๏ Viadeo - 35 million user professional network 14 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  35. 35. Case Study: Viadeo ๏ Viadeo - 35 million user professional network ๏ the past tech 14 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  36. 36. Case Study: Viadeo ๏ Viadeo - 35 million user professional network ๏ the past tech • recommendations running on MySQL as a batch job 14 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  37. 37. Case Study: Viadeo ๏ Viadeo - 35 million user professional network ๏ the past tech • recommendations running on MySQL as a batch job • took an hour, then success happened.. and it took two days 14 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  38. 38. Case Study: Viadeo ๏ Viadeo - 35 million user professional network ๏ the past tech • recommendations running on MySQL as a batch job • took an hour, then success happened.. and it took two days ๏ now using Neo4j 14 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  39. 39. Case Study: Viadeo ๏ Viadeo - 35 million user professional network ๏ the past tech • recommendations running on MySQL as a batch job • took an hour, then success happened.. and it took two days ๏ now using Neo4j • recommendations run in real-time 14 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  40. 40. Case Study: Viadeo ๏ Viadeo - 35 million user professional network ๏ the past tech • recommendations running on MySQL as a batch job • took an hour, then success happened.. and it took two days ๏ now using Neo4j • recommendations run in real-time • what does a recommendation look like? 14 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  41. 41. Case Study: Viadeo ๏ Viadeo - 35 million user professional network ๏ the past tech • recommendations running on MySQL as a batch job • took an hour, then success happened.. and it took two days ๏ now using Neo4j • recommendations run in real-time • what does a recommendation look like? 14 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  42. 42. Case Study: Viadeo ๏ Viadeo - 35 million user professional network ๏ the past tech • recommendations running on MySQL as a batch job • took an hour, then success happened.. and it took two days ๏ now using Neo4j • recommendations run in real-time • what does a recommendation look like? ๏ Check out: http://www.youtube.com/watch?v=sLlbtoCfciE 14 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  43. 43. A closer look at recommendations 15 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  44. 44. Recommendations 2 ways... 16 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  45. 45. Recommendations 2 ways... ๏Gremlin - graph scripting 16 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  46. 46. Recommendations 2 ways... ๏Gremlin - graph scripting • an algorithmic approach 16 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  47. 47. Recommendations 2 ways... ๏Gremlin - graph scripting • an algorithmic approach ๏Cypher - declarative querying 16 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  48. 48. Recommendations 2 ways... ๏Gremlin - graph scripting • an algorithmic approach ๏Cypher - declarative querying • a “pattern matching” approach 16 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  49. 49. Recommendations 2 ways... ๏Gremlin - graph scripting • an algorithmic approach ๏Cypher - declarative querying • a “pattern matching” approach ๏Stig - functional graph query 16 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  50. 50. Recommendations 2 ways... ๏Gremlin - graph scripting • an algorithmic approach ๏Cypher - declarative querying • a “pattern matching” approach ๏Stig - functional graph query • ok, not yet... Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4j 16Wednesday, August 24, 11
  51. 51. Gremlin 17 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  52. 52. Gremlin ๏ a graph scripting DSL 17 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  53. 53. Gremlin ๏ a graph scripting DSL ๏ part of the TinkerPop stack 17 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  54. 54. Gremlin ๏ a graph scripting DSL ๏ part of the TinkerPop stack ๏ try it out: 17 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  55. 55. Gremlin ๏ a graph scripting DSL ๏ part of the TinkerPop stack ๏ try it out: • g - the graph itself 17 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  56. 56. Gremlin ๏ a graph scripting DSL ๏ part of the TinkerPop stack ๏ try it out: • g - the graph itself • g.v(0) - node 0 17 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  57. 57. Gremlin ๏ a graph scripting DSL ๏ part of the TinkerPop stack ๏ try it out: • g - the graph itself • g.v(0) - node 0 • g.v(0).in - nodes connected to Node 0 17 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  58. 58. Gremlin ๏ a graph scripting DSL ๏ part of the TinkerPop stack ๏ try it out: • g - the graph itself • g.v(0) - node 0 • g.v(0).in - nodes connected to Node 0 • g.v(1).out(“KNOWS”) - nodes connected by “KNOWS” 17 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  59. 59. Gremlin ๏ a graph scripting DSL ๏ part of the TinkerPop stack ๏ try it out: • g - the graph itself • g.v(0) - node 0 • g.v(0).in - nodes connected to Node 0 • g.v(1).out(“KNOWS”) - nodes connected by “KNOWS” ๏ details about Gremlin: https://github.com/tinkerpop/gremlin 17 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  60. 60. Gremlin ๏ a graph scripting DSL ๏ part of the TinkerPop stack ๏ try it out: • g - the graph itself • g.v(0) - node 0 • g.v(0).in - nodes connected to Node 0 • g.v(1).out(“KNOWS”) - nodes connected by “KNOWS” ๏ details about Gremlin: https://github.com/tinkerpop/gremlin ๏ props to @twarko for creating it 17 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  61. 61. Cypher 18 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  62. 62. Cypher ๏ a pattern-matching query language (SQL-ish) 18 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  63. 63. Cypher ๏ a pattern-matching query language (SQL-ish) ๏ developed in-house 18 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  64. 64. Cypher ๏ a pattern-matching query language (SQL-ish) ๏ developed in-house ๏ try it out: 18 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  65. 65. Cypher ๏ a pattern-matching query language (SQL-ish) ๏ developed in-house ๏ try it out: • start a=(0) return a - get node 0 18 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  66. 66. Cypher ๏ a pattern-matching query language (SQL-ish) ๏ developed in-house ๏ try it out: • start a=(0) return a - get node 0 • start a=(1) match (a)-->(b) return b - traverse from node 1 18 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  67. 67. Cypher ๏ a pattern-matching query language (SQL-ish) ๏ developed in-house ๏ try it out: • start a=(0) return a - get node 0 • start a=(1) match (a)-->(b) return b - traverse from node 1 • start a=(1) match (a)--()--(c) return c - friends of friends 18 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  68. 68. Cypher ๏ a pattern-matching query language (SQL-ish) ๏ developed in-house ๏ try it out: • start a=(0) return a - get node 0 • start a=(1) match (a)-->(b) return b - traverse from node 1 • start a=(1) match (a)--()--(c) return c - friends of friends ๏ details about Cypher: 18 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  69. 69. Cypher ๏ a pattern-matching query language (SQL-ish) ๏ developed in-house ๏ try it out: • start a=(0) return a - get node 0 • start a=(1) match (a)-->(b) return b - traverse from node 1 • start a=(1) match (a)--()--(c) return c - friends of friends ๏ details about Cypher: • http://docs.neo4j.org/chunked/stable/cypher-query-lang.html 18 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  70. 70. The Social Graph as a Data Graph 19 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  71. 71. The Usual Social Graph, is also data status body: presenting at NoSQL name:Andreas Now! like right now! status knows name: Marko knows body: mocking up a simplified social graph worked_at name: Peter likes employer:Neo Technology employer:Xilinx likes worked_at url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 20 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  72. 72. The Usual Social Graph, is also data status body: presenting at NoSQL name:Andreas Now! like right now! status me knows name: Marko knows body: mocking up a simplified social graph worked_at name: Peter likes employer:Neo Technology employer:Xilinx likes worked_at url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 20 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  73. 73. with the Usual “status tweets” status body: presenting at NoSQL name:Andreas Now! like right now! status knows name: Marko knows body: mocking up a simplified social graph worked_at name: Peter likes employer:Neo Technology employer:Xilinx likes worked_at url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 21 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  74. 74. with the Usual “status tweets” status body: presenting at NoSQL name:Andreas Now! like right now! status knows name: Marko knows body: mocking up a simplified social graph worked_at name: Peter likes employer:Neo Technology employer:Xilinx likes worked_at url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 21 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  75. 75. and the Usual Suspects status body: presenting at NoSQL name:Andreas Now! like right now! status knows name: Marko knows body: mocking up a simplified social graph worked_at name: Peter likes employer:Neo Technology employer:Xilinx likes worked_at url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 22 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  76. 76. and the Usual Suspects status body: presenting at NoSQL name:Andreas Now! like right now! status knows name: Marko knows body: mocking up a simplified social graph worked_at name: Peter likes employer:Neo Technology employer:Xilinx likes worked_at url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 22 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  77. 77. and the Usual Business status body: presenting at NoSQL name:Andreas Now! like right now! status knows name: Marko knows body: mocking up a simplified social graph worked_at name: Peter likes employer:Neo Technology employer:Xilinx likes worked_at url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 23 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  78. 78. and the Usual Business status body: presenting at NoSQL name:Andreas Now! like right now! status knows name: Marko knows body: mocking up a simplified social graph worked_at name: Peter likes employer:Neo Technology employer:Xilinx likes worked_at url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 23 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  79. 79. and the Usual Likes status body: presenting at NoSQL name:Andreas Now! like right now! status knows name: Marko knows body: mocking up a simplified social graph worked_at name: Peter likes employer:Neo Technology employer:Xilinx likes worked_at url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 24 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  80. 80. and the Usual Likes status body: presenting at NoSQL name:Andreas Now! like right now! status knows name: Marko knows body: mocking up a simplified social graph worked_at name: Peter likes employer:Neo Technology employer:Xilinx likes worked_at url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 24 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  81. 81. Making Friends 25 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  82. 82. My Expanded Ego Network name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows knows knows name: Emil knows name: Allison knows 26 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  83. 83. Me & My Friends name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows knows knows name: Emil knows name: Allison knows 27 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  84. 84. Me & My Friends name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows knows knows name: Emil knows name: Allison knows 27 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  85. 85. Friends of my Friends name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows knows knows name: Emil knows name: Allison knows 28 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  86. 86. Friends of my Friends name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows knows knows name: Emil knows name: Allison knows 28 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  87. 87. Friends of my Friends name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows knows knows name: Emil knows name: Allison knows 28 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  88. 88. Friend of a Friend of a Friend? name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows knows knows name: Emil knows name: Allison knows 29 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  89. 89. Friend of a Friend of a Friend? name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows knows knows name: Emil knows name: Allison knows 29 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  90. 90. Friend of a Friend of a Friend? name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows knows knows name: Emil knows name: Allison knows Whatever. 29 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  91. 91. Query for Friends of Friends 30 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  92. 92. Query for Friends of Friends // Gremlin - andreas to friends to their friends, counted 30 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  93. 93. Query for Friends of Friends // Gremlin - andreas to friends to their friends, counted andreas.out(KNOWS).out(KNOWS).name.groupCount(m) 30 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  94. 94. Query for Friends of Friends // Gremlin - andreas to friends to their friends, counted andreas.out(KNOWS).out(KNOWS).name.groupCount(m) 30 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  95. 95. Query for Friends of Friends // Gremlin - andreas to friends to their friends, counted andreas.out(KNOWS).out(KNOWS).name.groupCount(m) // Cypher - match from andreas to friends to their friends 30 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  96. 96. Query for Friends of Friends // Gremlin - andreas to friends to their friends, counted andreas.out(KNOWS).out(KNOWS).name.groupCount(m) // Cypher - match from andreas to friends to their friends start andreas=(1) match (andreas)-[:KNOWS]->(friends) 30 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  97. 97. Query for Friends of Friends // Gremlin - andreas to friends to their friends, counted andreas.out(KNOWS).out(KNOWS).name.groupCount(m) // Cypher - match from andreas to friends to their friends start andreas=(1) match (andreas)-[:KNOWS]->(friends) -[:KNOWS]->(foafs) return foafs 30 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  98. 98. Query for Friends of Friends // Gremlin - andreas to friends to their friends, counted andreas.out(KNOWS).out(KNOWS).name.groupCount(m) // Cypher - match from andreas to friends to their friends start andreas=(1) match (andreas)-[:KNOWS]->(friends) -[:KNOWS]->(foafs) return foafs 30 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  99. 99. Query for Friends of Friends // Gremlin - andreas to friends to their friends, counted andreas.out(KNOWS).out(KNOWS).name.groupCount(m) // Cypher - match from andreas to friends to their friends start andreas=(1) match (andreas)-[:KNOWS]->(friends) -[:KNOWS]->(foafs) return foafs // result: Emil, Stephen, Allison (& Peter?) 30 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  100. 100. Query for Friends of Friends // Gremlin - andreas to friends to their friends, counted andreas.out(KNOWS).out(KNOWS).name.groupCount(m) // Cypher - match from andreas to friends to their friends start andreas=(1) match (andreas)-[:KNOWS]->(friends) -[:KNOWS]->(foafs) return foafs // result: Emil, Stephen, Allison (& Peter?) Is that good enough? 30 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  101. 101. Ranking my Friends’ Friends (intuitively) name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows knows knows name: Emil knows name: Allison knows 31 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  102. 102. Ranking my Friends’ Friends (intuitively) name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows 1 knows knows name: Emil knows name: Allison knows 31 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  103. 103. Ranking my Friends’ Friends (intuitively) name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows 1 knows knows name: Emil 2 knows name: Allison knows 31 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  104. 104. Ranking my Friends’ Friends (intuitively) 3 name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter name: Delia name: Tiberius knows 1 knows knows name: Emil 2 knows name: Allison knows 31 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  105. 105. Ranking my Friends’ Friends (intuitively) 3 name:Andreas knows knows name: Marko knows name: Stephen knows knows knows name: Peter ? name: Delia name: Tiberius knows 1 knows knows name: Emil 2 knows name: Allison knows 31 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  106. 106. Query for Ranked extended FoaF 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  107. 107. Query for Ranked extended FoaF // Gremlin - a bit more complex 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  108. 108. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  109. 109. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights // - weights decrease with each “hop” outward 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  110. 110. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights // - weights decrease with each “hop” outward // - extended hop, to include Stephen 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  111. 111. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights // - weights decrease with each “hop” outward // - extended hop, to include Stephen andreas.out(KNOWS).aggregate(x).out(KNOWS).except(x).name 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  112. 112. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights // - weights decrease with each “hop” outward // - extended hop, to include Stephen andreas.out(KNOWS).aggregate(x).out(KNOWS).except(x).name .groupCount(m){it}{it+1.0}.back(2) 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  113. 113. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights // - weights decrease with each “hop” outward // - extended hop, to include Stephen andreas.out(KNOWS).aggregate(x).out(KNOWS).except(x).name .groupCount(m){it}{it+1.0}.back(2) .out(KNOWS).except(x).name.groupCount(m){it}{it+0.5} 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  114. 114. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights // - weights decrease with each “hop” outward // - extended hop, to include Stephen andreas.out(KNOWS).aggregate(x).out(KNOWS).except(x).name .groupCount(m){it}{it+1.0}.back(2) .out(KNOWS).except(x).name.groupCount(m){it}{it+0.5} 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  115. 115. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights // - weights decrease with each “hop” outward // - extended hop, to include Stephen andreas.out(KNOWS).aggregate(x).out(KNOWS).except(x).name .groupCount(m){it}{it+1.0}.back(2) .out(KNOWS).except(x).name.groupCount(m){it}{it+0.5} ==>Emil=2.0 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  116. 116. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights // - weights decrease with each “hop” outward // - extended hop, to include Stephen andreas.out(KNOWS).aggregate(x).out(KNOWS).except(x).name .groupCount(m){it}{it+1.0}.back(2) .out(KNOWS).except(x).name.groupCount(m){it}{it+0.5} ==>Emil=2.0 ==>Allison=2.0 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  117. 117. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights // - weights decrease with each “hop” outward // - extended hop, to include Stephen andreas.out(KNOWS).aggregate(x).out(KNOWS).except(x).name .groupCount(m){it}{it+1.0}.back(2) .out(KNOWS).except(x).name.groupCount(m){it}{it+0.5} ==>Emil=2.0 ==>Allison=2.0 ==>Stephen=1.0 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  118. 118. Query for Ranked extended FoaF // Gremlin - a bit more complex // - requiring “memory” and weights // - weights decrease with each “hop” outward // - extended hop, to include Stephen andreas.out(KNOWS).aggregate(x).out(KNOWS).except(x).name .groupCount(m){it}{it+1.0}.back(2) .out(KNOWS).except(x).name.groupCount(m){it}{it+0.5} ==>Emil=2.0 ==>Allison=2.0 ==>Stephen=1.0 ==>Tiberius=0.5 32 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  119. 119. Like, like this 33 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  120. 120. What else might I like? url: http://theoatmeal.com/comics/ name:Andreas state_web_summer/ likes:+1 knows name: Marko likes:+2 url: http://www.imdb.com/title/tt0133093/ knows likes:+1 name: Peter likes:+1 url: http://browsertoolkit.com/fault- tolerance.png likes:+1 likes:+2 url: http://www.imdb.com/title/tt0436992/ likes:+1 likes:+3 url: http://lensbaby.com/optics-pinhole.php url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 34 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  121. 121. What else might I like? url: http://theoatmeal.com/comics/ name:Andreas state_web_summer/ likes:+1 knows name: Marko likes:+2 url: http://www.imdb.com/title/tt0133093/ knows likes:+1 name: Peter likes:+1 url: http://browsertoolkit.com/fault- tolerance.png likes:+1 likes:+2 url: http://www.imdb.com/title/tt0436992/ likes:+1 likes:+3 url: http://lensbaby.com/optics-pinhole.php url: http://www.amazon.com/Nikon-14-24mm-2-8G-Nikkor-Angle/dp/B000VDCTCI/ url: http://www.imdb.com/title/tt1475582/ 34 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  122. 122. Query for Things to Like 35 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  123. 123. Query for Things to Like // Cypher - websites my friends like 35 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  124. 124. Query for Things to Like // Cypher - websites my friends like start andreas=(1) match (andreas)-[:KNOWS]->(friend) 35 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  125. 125. Query for Things to Like // Cypher - websites my friends like start andreas=(1) match (andreas)-[:KNOWS]->(friend) -[:LIKES]->(website) return website.url 35 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11
  126. 126. Query for Things to Like // Cypher - websites my friends like start andreas=(1) match (andreas)-[:KNOWS]->(friend) -[:LIKES]->(website) return website.url 35 Andreas Kollegger --[known_as]--> @akollegger --[talks_about]--> #neo4jWednesday, August 24, 11

×