Intro to Neo4j presentation

9.888 Aufrufe

Veröffentlicht am

An introduction of the Neo4j Graph database. Introduces the NOSQL space, the Graph Database concept, and Neo4j with examples.

Veröffentlicht in: Technologie
0 Kommentare
17 Gefällt mir
Statistik
Notizen
  • Als Erste(r) kommentieren

Keine Downloads
Aufrufe
Aufrufe insgesamt
9.888
Auf SlideShare
0
Aus Einbettungen
0
Anzahl an Einbettungen
28
Aktionen
Geteilt
0
Downloads
1.091
Kommentare
0
Gefällt mir
17
Einbettungen 0
Keine Einbettungen

Keine Notizen für die Folie
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • social networks (our actions in them work life health)\nthe internet\nits hardware\nits software\nour interactions\nour body\nnature environment\npolitical economic networks\nzusammenhaenge\nhistory\nscience\nzeit grünen abgeordneter handy\n
  • messy world\nfast changing world\nbez um graph sind teil der daten\nim rdbms teil des starren schemas\nkomplexe zusammenhaenge\nkomplexe fragen\nimmer neue kategorien - rels\ndynamisch - traversals\ntags attribute\ntemporale attribute\ndyn sprachen besser geeignet \n
  • messy world\nfast changing world\nbez um graph sind teil der daten\nim rdbms teil des starren schemas\nkomplexe zusammenhaenge\nkomplexe fragen\nimmer neue kategorien - rels\ndynamisch - traversals\ntags attribute\ntemporale attribute\ndyn sprachen besser geeignet \n
  • messy world\nfast changing world\nbez um graph sind teil der daten\nim rdbms teil des starren schemas\nkomplexe zusammenhaenge\nkomplexe fragen\nimmer neue kategorien - rels\ndynamisch - traversals\ntags attribute\ntemporale attribute\ndyn sprachen besser geeignet \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Intro to Neo4j presentation

    1. 1. 1
    2. 2. Introduction to Neo4jMichael Hunger@mesirii#neo4j 2
    3. 3. Introduction to Neo4jMichael Hunger@mesirii#neo4j 2
    4. 4. Neo4j Introduction to Neo4jMichael Hunger@mesirii#neo4j 2
    5. 5. 2
    6. 6. (Michael) -[:WORKS_ON]-> (Neo4j) consoleCypher community graph Community MEServer Spring Cloud 3
    7. 7. 4
    8. 8. The Path Forward 4
    9. 9. The Path Forward1.No .. NO .. NOSQL 4
    10. 10. The Path Forward1.No .. NO .. NOSQL2.Why graphs? 4
    11. 11. The Path Forward1.No .. NO .. NOSQL2.Why graphs?3.Whats a graph database? 4
    12. 12. The Path Forward1.No .. NO .. NOSQL2.Why graphs?3.Whats a graph database?4.Some things about Neo4j. 4
    13. 13. The Path Forward1.No .. NO .. NOSQL2.Why graphs?3.Whats a graph database?4.Some things about Neo4j.5.How do people use Neo4j? 4
    14. 14. NOSQL 5
    15. 15. NOSQL Neo4j 5
    16. 16. Neo4j5
    17. 17. What is NOSQL? 6
    18. 18. What is NOSQL? 6
    19. 19. What is NOSQL? It’s not “No to SQL” 6
    20. 20. What is NOSQL? It’s not “No to SQL” It’s not “Never SQL” 6
    21. 21. What is NOSQL? It’s not “No to SQL” It’s not “Never SQL” It’s “Not Only SQL” 6
    22. 22. What is NOSQL? It’s not “No to SQL” It’s not “Never SQL” It’s “Not Only SQL” NOSQL no-seek-wool n. Describes ongoing trend where developers increasingly opt for non-relational databases to help solve their problems, in an effort to use the right tool for the right job. 6
    23. 23. NOSQL Databases Riak Couch KeyValueRedis Document NOSQL Mongo Column oriented Graph Neo4jCassandra Relational MySQL Postgres 7
    24. 24. 8
    25. 25. Living in a NOSQL World 8
    26. 26. Living in a NOSQL World Volume ~= Size 8
    27. 27. Living in a NOSQL WorldDensity ~= Complexity Volume ~= Size 8
    28. 28. Living in a NOSQL WorldDensity ~= Complexity Key-Value Store Volume ~= Size 8
    29. 29. Living in a NOSQL WorldDensity ~= Complexity Column Family Key-Value Store Volume ~= Size 8
    30. 30. Living in a NOSQL WorldDensity ~= Complexity Document Databases Column Family Key-Value Store Volume ~= Size 8
    31. 31. Living in a NOSQL World RDBMSDensity ~= Complexity Document Databases Column Family Key-Value Store Volume ~= Size 8
    32. 32. Living in a NOSQL World Graph Databases RDBMSDensity ~= Complexity Document Databases Column Family Key-Value Store Volume ~= Size 8
    33. 33. Living in a NOSQL World Graph Databases RDBMSDensity ~= Complexity Document Databases Column Family Key-Value Store 90% Volume ~= Size of use cases 8
    34. 34. Living in a NOSQL World Graph Databases RDBMSDensity ~= Complexity Document Databases Column Family Key-Value Store 90% Volume ~= Size of use cases 8
    35. 35. Trends in BigData & NOSQL 1. increasing data size (big data) • “Every 2 -days we create as much information as we did up to 2003” Eric Schmidt 2. increasingly connected data (graph data) • for example, text documents to html 3. semi-structured data • individualization of data, with common sub-set 4. architecture - a facade over multiple services • from monolithic to modular, distributed applications 9
    36. 36. 10
    37. 37. A Graph? 10
    38. 38. A Graph?Yes, a graph 10
    39. 39. They are everywhere Flight Patterns in Europe 11
    40. 40. Graphs Everywhere ๏ Relationships in • Politics, Economics, History, Science,Transportation ๏ Biology, Chemistry, Physics, Sociology • Body, Ecosphere, Reaction, Interactions ๏ Internet • Hardware, Software, Interaction ๏ Social Networks • Family, Friends • Work, Communities • Neighbours, Cities, Society 12
    41. 41. Good Relationships๏ the world is rich, messy and related data๏ relationships are as least as important as the things they connect๏ Graphs = Whole > Σ parts๏ complex interactions๏ always changing, change of structures as well๏ Graph: Relationships are part of the data๏ RDBMS: Relationships part of the fixed schema 13
    42. 42. Questions and Answers๏ Complex Questions๏ Answers lie between the lines (things)๏ Locality of the information๏ Global searches / operations very expensive๏ constant query time, regardless of data volume 14
    43. 43. Categories ?๏ Categories == Classes, Trees ?๏ What if more than one category fits?๏ Tags๏ Categories vi relationships like „IS_A“๏ any number, easy change๏ „virtual“ Relationships - Traversals๏ Category dynamically derived from queries 15
    44. 44. Fowler & Christakis „Connected“ 16
    45. 45. New York Times R&D „Cascade“ 17
    46. 46. Deb Roy - MIT & Bluefin Labs „Birth of a Word“ TED Talk Researches Social Reactions to (Media) Events 18
    47. 47. 19
    48. 48. Everyone is talking about graphs... 19
    49. 49. Everyone is talking about graphs...Facebook Open Graph 19
    50. 50. Everyone is talking about graphs...Facebook Open Graph 19
    51. 51. 20
    52. 52. Each of us has not only one graph, but many! 20
    53. 53. Graph DB 101 21
    54. 54. A graph database... 22
    55. 55. A graph database... NO: not for charts & diagrams, or vector artwork 22
    56. 56. A graph database... NO: not for charts & diagrams, or vector artwork YES: for storing data that is structured as a graph 22
    57. 57. A graph database... NO: not for charts & diagrams, or vector artwork YES: for storing data that is structured as a graph remember linked lists, trees? 22
    58. 58. A graph database... NO: not for charts & diagrams, or vector artwork YES: for storing data that is structured as a graph remember linked lists, trees? graphs are the general-purpose data structure 22
    59. 59. A graph database... NO: not for charts & diagrams, or vector artwork YES: for storing data that is structured as a graph remember linked lists, trees? graphs are the general-purpose data structure “A relational database may tell you the average age of everyone in this session, but a graph database will tell you who is most likely to buy you a beer.” 22
    60. 60. 23
    61. 61. You know relational 23
    62. 62. You know relational 23
    63. 63. You know relational foo 23
    64. 64. You know relational foo bar 23
    65. 65. You know relational foo foo_bar bar 23
    66. 66. You know relational foo foo_bar bar 23
    67. 67. You know relational foo foo_bar bar 23
    68. 68. You know relational foo foo_bar bar 23
    69. 69. You know relationalnow consider relationships... 23
    70. 70. You know relationalnow consider relationships... 23
    71. 71. You know relationalnow consider relationships... 23
    72. 72. You know relationalnow consider relationships... 23
    73. 73. You know relationalnow consider relationships... 23
    74. 74. You know relationalnow consider relationships... 23
    75. 75. 23
    76. 76. 24
    77. 77. Were talking about aProperty Graph 24
    78. 78. Were talking about aProperty Graph Nodes 24
    79. 79. Were talking about aProperty Graph Nodes Relationships 24
    80. 80. Were talking about aProperty 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) 24
    81. 81. 24
    82. 82. 25
    83. 83. Looks different, fine. Who cares? 25
    84. 84. Looks different, fine. Who cares?๏ a sample social graph 25
    85. 85. Looks different, fine. Who cares?๏ a sample social graph • with ~1,000 persons 25
    86. 86. Looks different, fine. Who cares?๏ a sample social graph • with ~1,000 persons๏ average 50 friends per person 25
    87. 87. Looks different, fine. Who cares?๏ a sample social graph • with ~1,000 persons๏ average 50 friends per person๏ pathExists(a,b) limited to depth 4 25
    88. 88. Looks different, fine. Who cares?๏ a sample social graph • with ~1,000 persons๏ average 50 friends per person๏ pathExists(a,b) limited to depth 4๏ caches warmed up to eliminate disk I/O 25
    89. 89. Looks different, fine. Who cares?๏ a sample social graph • with ~1,000 persons๏ average 50 friends per person๏ pathExists(a,b) limited to depth 4๏ caches warmed up to eliminate disk I/O # persons query time Relational database 1,000 2000ms Neo4j 1,000 2ms Neo4j 1,000,000 2ms 25
    90. 90. Looks different, fine. Who cares?๏ a sample social graph • with ~1,000 persons๏ average 50 friends per person๏ pathExists(a,b) limited to depth 4๏ caches warmed up to eliminate disk I/O # persons query time Relational database 1,000 2000ms Neo4j 1,000 2ms Neo4j 1,000,000 2ms 25
    91. 91. Looks different, fine. Who cares?๏ a sample social graph • with ~1,000 persons๏ average 50 friends per person๏ pathExists(a,b) limited to depth 4๏ caches warmed up to eliminate disk I/O # persons query time Relational database 1,000 2000ms Neo4j 1,000 2ms Neo4j 1,000,000 2ms 25
    92. 92. 25
    93. 93. Graph Database: Pros & Cons๏ Strengths • Powerful data model, as general as RDBMS • Fast, for connected data • Easy to query๏ Weaknesses: • Sharding (though they can scale reasonably well) ‣also, stay tuned for developments here • Requires conceptual shift ‣though graph-like thinking becomes addictive 26
    94. 94. 27
    95. 95. And, but, so how do youquery this "graph" database? 27
    96. 96. 28
    97. 97. Query a graph with a traversal 28
    98. 98. Query a graph with a traversal 28
    99. 99. Query a graph with a traversal// lookup starting point in an indexstart n=node:People(name = ‘Andreas’) And rea s 28
    100. 100. Query a graph with a traversal// lookup starting point in an index then traverse to find resultsstart n=node:People(name = ‘Andreas’) match (n)--()--(foaf) return foaf And rea s 28
    101. 101. 28
    102. 102. Neo4j - the Graph Database 29
    103. 103. 30
    104. 104. (Neo4j) -[:IS_A]-> (Graph Database) LuceneSharding 1 M/s Master/ Index LS Slave TRAVERSA HIG TES H_A VA RA G IL. TE IN PROVIDES ACID Server RUN S_A LI TX S CE NS ED _L ES_T Ruby IK RU JS E MySQL S _A NS SC AL OClojure _O NS .net RU N Mongo 34bn embedded Heroku Nodes 31
    105. 105. Neo4j is a Graph Database 32
    106. 106. Neo4j is a Graph Database๏ A Graph Database: 32
    107. 107. Neo4j is a Graph Database๏ A Graph Database: • a schema-free Property Graph 32
    108. 108. Neo4j is a Graph Database๏ A Graph Database: • a schema-free Property Graph • perfect for complex, highly connected data 32
    109. 109. Neo4j is a Graph Database๏ A Graph Database: • a schema-free Property Graph • perfect for complex, highly connected data๏ A Graph Database: 32
    110. 110. Neo4j is a Graph Database๏ A Graph Database: • a schema-free Property Graph • perfect for complex, highly connected data๏ A Graph Database: • reliable with real ACID Transactions 32
    111. 111. Neo4j is a Graph Database๏ A Graph Database: • a schema-free Property Graph • perfect for complex, highly connected data๏ A Graph Database: • reliable with real ACID Transactions • scalable: 32 Billion Nodes, 32 Billion Relationships, 64 Billion Properties 32
    112. 112. Neo4j is a Graph Database๏ A Graph Database: • a schema-free Property Graph • perfect for complex, highly connected data๏ A Graph Database: • reliable with real ACID Transactions • scalable: 32 Billion Nodes, 32 Billion Relationships, 64 Billion Properties • fast with more than 1M traversals / second 32
    113. 113. Neo4j is a Graph Database๏ A Graph Database: • a schema-free Property Graph • perfect for complex, highly connected data๏ A Graph Database: • reliable with real ACID Transactions • scalable: 32 Billion Nodes, 32 Billion Relationships, 64 Billion Properties • fast with more than 1M traversals / second • Server with REST API, or Embeddable on the JVM 32
    114. 114. Neo4j is a Graph Database๏ A Graph Database: • a schema-free Property Graph • perfect for complex, highly connected data๏ A Graph Database: • reliable with real ACID Transactions • scalable: 32 Billion Nodes, 32 Billion Relationships, 64 Billion Properties • fast with more than 1M traversals / second • Server with REST API, or Embeddable on the JVM • higher-performance with High-Availability (read scaling) 32
    115. 115. Whiteboard --> Data 33
    116. 116. Whiteboard --> Data Peter Andreas Allison Emil 33
    117. 117. Whiteboard --> Data Peter Andreas knows knows knows Allison knows Emil 33
    118. 118. Whiteboard --> Data Peter Andreas knows knows knows Allison knows Emil 33
    119. 119. Whiteboard --> Data Peter Andreas knows knows knows Allison knows Emil // Cypher query - friend of a friend start n=node(0) match (n)--()--(foaf) return foaf 33
    120. 120. 34
    121. 121. Two Ways to Work with Neo4j 34
    122. 122. Two Ways to Work with Neo4j๏ 1. Embeddable on JVM 34
    123. 123. Two Ways to Work with Neo4j๏ 1. Embeddable on JVM • Java, JRuby, Scala... 34
    124. 124. Two Ways to Work with Neo4j๏ 1. Embeddable on JVM • Java, JRuby, Scala... • Tomcat, Rails, Akka, etc. 34
    125. 125. Two Ways to Work with Neo4j๏ 1. Embeddable on JVM • Java, JRuby, Scala... • Tomcat, Rails, Akka, etc. • great for testing 34
    126. 126. Two Ways to Work with Neo4j๏ 1. Embeddable on JVM • Java, JRuby, Scala... • Tomcat, Rails, Akka, etc. • great for testing 34
    127. 127. Two Ways to Work with Neo4j๏ 1. Embeddable on JVM • Java, JRuby, Scala... • Tomcat, Rails, Akka, etc. • great for testing 34
    128. 128. Two Ways to Work with Neo4j๏ 1. Embeddable on JVM • Java, JRuby, Scala... • Tomcat, Rails, Akka, etc. • great for testing 34
    129. 129. Two Ways to Work with Neo4j๏ 1. Embeddable on JVM • Java, JRuby, Scala... • Tomcat, Rails, Akka, etc. • great for testing 34
    130. 130. Two Ways to Work with Neo4j๏ 1. Embeddable on JVM • Java, JRuby, Scala... • Tomcat, Rails, Akka, etc. • great for testing 34
    131. 131. Two Ways to Work with Neo4j 34
    132. 132. Show me some code, please GraphDatabaseService graphDb = new EmbeddedGraphDatabase(“var/neo4j”); Transaction tx = graphDb.beginTx(); try { Node steve = graphDb.createNode(); Node michael = graphDb.createNode(); steve.setProperty(“name”, “Steve Vinoski”); michael.setProperty(“name”, “Michael Hunger”); Relationship presentedWith = steve.createRelationshipTo( michael, PresentationTypes.PRESENTED_WITH); presentedWith.setProperty(“date”, today); tx.success(); } finally { tx.finish(); }
    133. 133. Spring Data Neo4j @NodeEntity public class Movie { @Indexed private String title; @RelatedToVia(type = “ACTS_IN”, direction=INCOMING) private Set<Role> cast; private Director director; } @NodeEntity public class Actor { @RelatedTo(type = “ACTS_IN”) private Set<Movies> movies; } @RelationshipEntity public class Role { @StartNode private Actor actor; @EndNode private Movie movie; private String roleName; }
    134. 134. neo4j.rb gem install neo4j require rubygems require neo4j class Person include Neo4j::NodeMixin property :name, :age, :rank index :name has_n :friends end Neo4j::Transaction.run do neo = Person.new :name=>Neo, :age=>29 morpheus = Person.new :name=>Morpheus, :rank=>Captain neo.friends << morpheus end neo.friends.each {|p|...}
    135. 135. Cypher Query Language๏ Declarative query language • Describe what you want, not how • Based on pattern matching๏ Examples: START david=node:people(name=”David”) # index lookup MATCH david-[:knows]-friends-[:knows]-new_friends WHERE new_friends.age > 18 RETURN new_friends START user=node(5, 15, 26, 28) # node IDs MATCH user--friend RETURN user, COUNT(friend), SUM(friend.money) 38
    136. 136. Create Graph with Cypher CREATE (steve {name: “Steve Vinoski”}) -[:PRESENTED_WITH {date:{day}}]-> (michael {name: “Michael Hunger”})
    137. 137. Two Ways to Work with Neo4j 40
    138. 138. Two Ways to Work with Neo4j๏ 2. Server with REST API 40
    139. 139. Two Ways to Work with Neo4j๏ 2. Server with REST API • every language on the planet 40
    140. 140. Two Ways to Work with Neo4j๏ 2. Server with REST API • every language on the planet • flexible deployment scenarios 40
    141. 141. Two Ways to Work with Neo4j๏ 2. Server with REST API • every language on the planet • flexible deployment scenarios • DIY server, or cloud managed 40
    142. 142. Two Ways to Work with Neo4j๏ 2. Server with REST API • every language on the planet • flexible deployment scenarios • DIY server, or cloud managed 40
    143. 143. Two Ways to Work with Neo4j๏ 2. Server with REST API • every language on the planet • flexible deployment scenarios • DIY server, or cloud managed 40
    144. 144. Two Ways to Work with Neo4j๏ 2. Server with REST API • every language on the planet • flexible deployment scenarios • DIY server, or cloud managed 40
    145. 145. Two Ways to Work with Neo4j๏ 2. Server with REST API • every language on the planet • flexible deployment scenarios • DIY server, or cloud managed 40
    146. 146. Two Ways to Work with Neo4j 40
    147. 147. Bindings REST:// 41
    148. 148. Two Ways to Work with Neo4j 42
    149. 149. Two Ways to Work with Neo4j๏ Server capability == Embedded capability 42
    150. 150. Two Ways to Work with Neo4j๏ Server capability == Embedded capability • same scalability, transactionality, and availability 42
    151. 151. Two Ways to Work with Neo4j๏ Server capability == Embedded capability • same scalability, transactionality, and availability 42
    152. 152. Two Ways to Work with Neo4j๏ Server capability == Embedded capability • same scalability, transactionality, and availability 42
    153. 153. 42
    154. 154. How to get started? 43
    155. 155. How to get started?๏ Documentation 43
    156. 156. How to get started?๏ Documentation • docs.neo4j.org - tutorials+reference 43
    157. 157. How to get started?๏ Documentation • docs.neo4j.org - tutorials+reference • Neo4j in Action 43
    158. 158. How to get started?๏ Documentation • docs.neo4j.org - tutorials+reference • Neo4j in Action • Good Relationships 43
    159. 159. How to get started?๏ Documentation • docs.neo4j.org - tutorials+reference • Neo4j in Action • Good Relationships๏ Get Neo4j 43
    160. 160. How to get started?๏ Documentation • docs.neo4j.org - tutorials+reference • Neo4j in Action • Good Relationships๏ Get Neo4j • http://neo4j.org/download 43
    161. 161. How to get started?๏ Documentation • docs.neo4j.org - tutorials+reference • Neo4j in Action • Good Relationships๏ Get Neo4j • http://neo4j.org/download • http://addons.heroku.com/neo4j/ 43
    162. 162. How to get started?๏ Documentation • docs.neo4j.org - tutorials+reference • Neo4j in Action • Good Relationships๏ Get Neo4j • http://neo4j.org/download • http://addons.heroku.com/neo4j/๏ Participate • http://groups.google.com/group/neo4j • http://neo4j.meetup.com • a session like this one ;) 43
    163. 163. Thank you! 44

    ×