Advertisement
Jakzon123

Mod 10 Cypher Queries

May 3rd, 2023
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. 2) Count all the nodes (2 points)
  2. MATCH(N)
  3. count(N)
  4.  
  5. 3) Count all relationships (2 points)
  6. MATCH ()-[r]->()
  7. RETURN count(r) as count
  8.  
  9. 4) Return all nodes specific type (2 points)
  10. MATCH(n:Answer)
  11. RETURN count(n) as count
  12.  
  13. 5) Return all nodes specific type and limit results (2 points)
  14. MATCH(n:User)
  15. RETURN n
  16. LIMIT 5
  17.  
  18. 6) Return all nodes that where an attribute matches a literal of your choosing (2 points)
  19. MATCH (n:Answer {is_accepted: true})
  20. RETURN n
  21.  
  22. 7) Return all nodes that where a string attribute starts with a literal of your choosing (2 points)
  23. MATCH (n:User)
  24. WHERE n.display_name STARTS WITH ‘D’
  25. RETURN n
  26.  
  27. 8) Return all nodes that where a string attribute ends with a literal of your choosing (2 points)
  28. MATCH (n:User)
  29. WHERE n.display_name ENDS WITH ‘er’
  30. RETURN n
  31.  
  32. 9) Return all nodes that where a string attribute contains a literal of your choosing (2 points)
  33. MATCH (n:User)
  34. WHERE n.display_name CONTAINS ‘con’
  35. RETURN n
  36.  
  37. 10) Return a nodes attribute (2 points)
  38. MATCH (n)
  39. RETURN n.uuid
  40. LIMIT 1
  41.  
  42. 11) Find nodes with specific relationships (2 points)
  43. MATCH (a)-[:ANSWERED]-(b)
  44. RETURN a,b
  45.  
  46. 12) Find nodes with specific relationships where an attribute matches a literal of your choosing (2 points)
  47. MATCH (a)-[:ANSWERED]-(b)
  48. WHER a.display_name = “Damian Grzanka”
  49. RETURN a,b
  50.  
  51. 13) Find nodes with more than 1 specific relationship (2 points)
  52. MATCH (a)-[:ANSWERED|COMMENTED]-(b)
  53. WHER a.display_name = “Damian Grzanka”
  54. RETURN a,b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement