Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

[Webinar] Introduction to Cypher

162 vues

Publié le

Maria Scharin, Neo4j

Publié dans : Technologie
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

[Webinar] Introduction to Cypher

  1. 1. Maria Scharin maria.scharin@neo4j.com Introduction to Cypher
  2. 2. Information Developer IT Project Manager Oracle DBA About Me maria.scharin@neo4j.com
  3. 3. • A brief history of graph databases • Graph thinking • Graph data modelling • Importing data • How to get started Agenda
  4. 4. A brief history of graph databases
  5. 5. Everything and Everyone is Connected • people, places, events • companies, markets • countries, history, politics • sciences, art, teaching • technology, networks, machines, applications, users • software, code, dependencies, architecture, deployments • criminals, fraudsters and their behavior

  6. 6. Seven Bridges of Königsberg
  7. 7. C 34,3%B 38,4%A 3,3% D 3,8% 1,8% 1,8% 1,8% 1,8% 1,8% E 8,1% F 3,9% Static world Connected World Native Graph Platform Neo4j is an internet-scale, native graph database which executes connected workloads faster than any other database management system. Neo4j
  8. 8. Ecosystem Neo4j Professional Services 300+ partners 47,000 group members 61,000 trained engineers 3.5M downloads Mindset “Graph Thinking” is all about considering connections in data as important as the data itself. Native Graph Platform Neo4j is an internet-scale, native graph database which executes connected workloads faster than any other database management system. Neo4j
  9. 9. Graph thinking
  10. 10. Graph thinking: A modern Swedish family Icons designed by Freepik www.freepik.com/free-vector/people-icons-collection_1024244.htm Maria OscarThomas Ann FRIEND OF MOTHER OFMOTHER OF FRIEND OF Cody EX OF FATHER OF
  11. 11. Graph thinking: A modern Swedish family Icons designed by Freepik www.freepik.com/free-vector/people-icons-collection_1024244.htm FRIEND OF MOTHER OF FRIEND OF Thomas Ann Cody EX OFMARRIED TO Dan
  12. 12. Graph thinking: A modern Swedish family Icons designed by Freepik www.freepik.com/free-vector/people-icons-collection_1024244.htm Karl Ben Chris Carrie Elizabeth EX OF FRIEND OF MOTHER OF FRIEND OF Thomas Ann Cody EX OFMARRIED TO Dan
  13. 13. Graph thinking
  14. 14. AnnDan LOVES The property graph model
  15. 15. since: Jan 10, 2011 brand: “Volvo” model: “V70” D R IVES O W NS Car LIVES_WITH LOVES name:”Dan” born: May 29, 1970 twitter:”@dan” name:”Ann” born: Dec 5, 1975 LOVES Person Person The property graph model
  16. 16. Cypher: The Graph Query Language • The “SQL for graphs”: An open language (http://www.opencypher.org/)
 • The formal semantics are in the process of being defined: collaboration with the University of Edinburgh, UK • Declarative • Focus on pattern matching • Intuitive and easy to learn (ASCII-Art)
  17. 17. Cypher: The Graph Query Language CREATE LABEL PROPERTYLABEL PROPERTY RELATIONSHIP TYPE (:Person { name:“Dan”} ) - [:LOVES]-> (:Person { name:“Ann”} ) NODE NODERELATIONSHIP name:”Dan” name:”Ann” LOVES Person Person MERGE
  18. 18. Index-free adjacency Credit: Dan McCreary https://medium.com/@dmccreary/how-to-explain-index-free-adjacency-to-your-manager-1a8e68ec664a Maria’s
 house Ann’s
 house
  19. 19. Index-free adjacency Credit: Dan McCreary https://medium.com/@dmccreary/how-to-explain-index-free-adjacency-to-your-manager-1a8e68ec664a
  20. 20. Relational and Other NoSQL Databases ResponseTime Connectedness and Size of Data Set 0 to 2 hops 0 to 3 degrees Few connections 5+ hops 3+ degrees Thousands of connections Neo4j Real-Time Query Performance
  21. 21. Graph data modelling
  22. 22. Graph data modeling • Relational to graph • Different ways of modelling • Refactoring • Inference • A social recommendation example
  23. 23. Relational to Graph select restaurant.name
 from person join review on (...) join restaurant on(…)
 where person.name = “Maria” reviewperson business Maria Sushi Lovers The Burger Joint Pedro’s Pizza
  24. 24. reviewperson business Relational model Rows Joins Table names Columns Graph model Nodes Relationships Labels Properties Maria Sushi Lovers Pedro’s
 Pizza The
 Burger
 Joint Relational to Graph
  25. 25. Arrow tool: http://www.apcjones.com/arrows/# Graph data modelling
  26. 26. Graph data modelling: refactoring Arrow tool: http://www.apcjones.com/arrows/#
  27. 27. Graph data modelling: inference Arrow tool: http://www.apcjones.com/arrows/#
  28. 28. A Social Recommendation Maria Ann Diana FRIEND OF FRIEND OF LIKES LIKES iSushi :Restaurant New York :Location Sushi :Cuisine SERVES SERVES LOCATED_IN LOCATED_IN Sushi Lovers :Restaurant Icons designed by Freepik www.freepik.com/free-vector/people-icons-collection_1024244.htm
  29. 29. A Social Recommendation Some icons designed by Freepik www.freepik.com/free-vector/people-icons-collection_1024244.htm Maria Ann Diana FRIEND OF FRIEND OF LIKES LIKES iSushi New York Sushi SERVES SERVES LOCATED_IN LOCATED_IN :Restaurant :Location :Cuisine :Restaurant Sushi Lovers
  30. 30. A Social Recommendation Some icons designed by Freepik www.freepik.com/free-vector/people-icons-collection_1024244.htm Maria Ann Diana FRIEND OF FRIEND OF LIKES LIKES iSushi New York Sushi SERVES SERVES LOCATED_IN LOCATED_IN :Restaurant :Location :Cuisine :Restaurant Sushi Lovers https://neo4j.com/docs/developer-manual/current/cypher/query-tuning/
  31. 31. A Social Recommendation Some icons designed by Freepik www.freepik.com/free-vector/people-icons-collection_1024244.htm Maria Ann Diana FRIEND OF FRIEND OF LIKES LIKES iSushi New York Sushi SERVES SERVES LOCATED_IN LOCATED_IN :Restaurant :Location :Cuisine Sushi Lovers :Restaurant
  32. 32. Import data
  33. 33. Download and install Neo4j Desktop https://neo4j.com/download/
  34. 34. Download and install Neo4j Desktop
  35. 35. The Yelp dataset https://www.yelp.com/dataset
  36. 36. The Yelp dataset https://www.yelp.com/dataset json format Convert json files to csv format: 
 https://github.com/johnymontana/neo4j-datasets/tree/master/yelp https://www.yelp.com/dataset
  37. 37. The Yelp dataset (Also available in sql) https://www.yelp.com/dataset
  38. 38. The Yelp dataset
  39. 39. Import data: LOAD CSV Cypher-Based LOAD CSV Capability • Transactional (ACID) writes • Initial and incremental loads of up to 10 million nodes and relationships • From HTTP and Files • Power of Cypher: • Create and update graph structures • Data conversion, filtering, aggregation • De-structuring of input data • Transaction size control • Via Neo4j Browser or cypher-shell • https://neo4j.com/docs/cypher-refcard/current/
  40. 40. Import data: LOAD CSV line ["yelping_since", "useful", "compliment_photos", "compliment_list", "compliment_funny", "funny", "review_count", "friends", "fans", "compliment_note", "compliment_plain", "compliment_writer", "compliment_cute", "average_stars", "user_id", "compliment_more", "elite", "compliment_hot", "cool", "name", "compliment_profile", "compliment_cool"] ["2014-11-03", "0", "0", "0", "0", "0", "8", "cvVMmlU1ouS3I5fhutaryQ;nj6UZ8tdGo8YJ9lUMTVWNw;RTtdEVhAmeWqCSp0IgJ99w;t3UKA1sl4e6LY_xsjuvI0A;s057_BvOfnKNvQquJf7VNg;VYrdepCgdzJ4WaxP7dBGpg;XXLSk6s QQDyr3dZ4zE-O0g;Py8ThfExQaXF2Woqr7kWUw;233YNvzVtZ1ObkaNkUzNIw;L6iE9NpmHHJQTk0JQlRlSA;Y7XTMgZ_q5Bj5f9KhK1R4Q", "[u'cvVMmlU1ouS3I5fhutaryQ', u'nj6UZ8tdGo8YJ9lUMTVWNw', u'RTtdEVhAmeWqCSp0IgJ99w', u't3UKA1sl4e6LY_xsjuvI0A', u's057_BvOfnKNvQquJf7VNg', u'VYrdepCgdzJ4WaxP7dBGpg', u'XXLSk6sQQDyr3dZ4zE-O0g', u'Py8ThfExQaXF2Woqr7kWUw', u'233YNvzVtZ1ObkaNkUzNIw', u'L6iE9NpmHHJQTk0JQlRlSA', u'Y7XTMgZ_q5Bj5f9KhK1R4Q']", "0", "0", "1", "0", "0", "4.67", "oMy_rEb0UBEmMlu-zcxnoQ", "0", "", "[]", "0", "0", "Johnny", "0", "0"] https://neo4j.com/docs/cypher-refcard/current/
  41. 41. Import data: LOAD CSV https://neo4j.com/docs/cypher-refcard/current/
  42. 42. Import data: LOAD CSV http://markhneedham.com/blog/2014/07/10/neo4j-load-csv-processing-hidden-arrays-in-your-csv-documents/
 https://neo4j.com/docs/cypher-refcard/current/
  43. 43. Import data: LOAD CSV https://neo4j.com/docs/cypher-refcard/current/
  44. 44. Import data: LOAD CSV https://neo4j.com/docs/cypher-refcard/current/
  45. 45. Use JDBC with your sql database
  46. 46. Use JDBC with your sql database apoc.load.jdbc  Access any database that provides a JDBC driver Execute queries whose results are turned into streams of rows Use the rows to update or create graph structures https://neo4j-contrib.github.io/neo4j-apoc-procedures/index30.html#_load_jdbc
  47. 47. Use JDBC with your sql database CALL apoc.load.jdbc(“jdbc:mysql://localhost:3306/yelp_db? user=user&password=pwd", “business") 
 YIELD row 
 RETURN row https://neo4j-contrib.github.io/neo4j-apoc-procedures/index30.html#_load_jdbc
  48. 48. Use JDBC with your sql database CALL apoc.load.jdbc("jdbc:mysql://localhost:3306/yelp_db? user=user&password=pwd", “business") YIELD row RETURN row.id, row.name, row.address, row.state https://neo4j-contrib.github.io/neo4j-apoc-procedures/index30.html#_load_jdbc
  49. 49. Use JDBC with your sql database CALL apoc.load.jdbc("jdbc:mysql://localhost:3306/yelp_db? user=user&password=pwd", “business") YIELD row MERGE (:Business {id: row.id, name:row.name, address:row.address, state:row.state}) https://neo4j-contrib.github.io/neo4j-apoc-procedures/index30.html#_load_jdbc
  50. 50. Import data: neo4j-admin import Command line bulk loader neo4j-admin import • For initial database population • Scale across CPUs and disk performance • Efficient RAM usage • Split- and compressed file support • For loads up to 10B+ records • Up to 1M records per second https://neo4j.com/docs/operations-manual/3.3/tutorial/import-tool/
  51. 51. • Neo4j Desktop - Free for download • Neo4j Browser (included in Neo4j Desktop) • Sandbox: neo4j.com/sandbox • Drivers - Official Drivers and Community Supported Drivers • Webinars and Tutorials • Community and Meetups Get started with Neo4j
  52. 52. Neo4j Sandbox https://neo4j.com/sandbox-v2/
  53. 53. Thank you! maria.scharin@neo4j.com

×