Fireship · @fireship

Neo4j in 100 Seconds

Uploaded January 24, 2023 · Length 2:37

Neo4j in 100 Seconds

Summary

neo4j graph database basics and querying with Cipher in 100 seconds

  • neo4j
  • graph database
  • cypher
  • property graph model
  • acid compliance

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    neo4j an acid compliant graph database

  2. 0:03

    that can handle the extremely complex

  3. 0:04

    relational data of the modern world it

  4. 0:07

    was created in 2007 by Emil ifram is

  5. 0:09

    written in Java and pioneered the

  6. 0:11

    property graph model traditional

  7. 0:13

    relational databases use a tabular model

  8. 0:15

    but joining normalized tables together

  9. 0:17

    is not how real humans think about

  10. 0:19

    relationships naturally we think about

  11. 0:20

    connections between entities like Bob

  12. 0:23

    asked a question on stack Overflow then

  13. 0:25

    Alice and Chad downvoted it so Bob gave

  14. 0:27

    up on his dream of programming a graph

  15. 0:29

    can model this data the same way you

  16. 0:30

    might visualize it on a whiteboard nodes

  17. 0:32

    represent entities edges represent

  18. 0:34

    relationships between entities and

  19. 0:36

    properties are key value pairs that

  20. 0:37

    store data on these objects under the

  21. 0:39

    hood neo4j is a true native graph

  22. 0:41

    database that applies this model all the

  23. 0:43

    way down to the storage level queries

  24. 0:45

    are written in a declarative language

  25. 0:46

    called Cipher that resembles SQL except

  26. 0:49

    nodes are surrounded by parentheses then

  27. 0:51

    connect to other nodes with arrows via

  28. 0:53

    relationships and brackets today neo4j

  29. 0:56

    is used in applications like

  30. 0:57

    recommendation engines social media

  31. 0:59

    platforms and knowledge graphs for

  32. 1:01

    artificial intelligence and just to name

  33. 1:03

    a few to get started it can be

  34. 1:04

    self-hosted with Docker but the easiest

  35. 1:06

    approach is to sign up for Aura which

  36. 1:08

    provides a free fully managed database

  37. 1:10

    in the cloud from there we can build the

  38. 1:12

    next Twitter by making queries with

  39. 1:13

    Cipher use create followed by

  40. 1:15

    parentheses to create a new entity or

  41. 1:17

    node this node has a label of user that

  42. 1:19

    can be used to group similar nodes

  43. 1:21

    together inside the braces we can add

  44. 1:23

    key value pairs to represent the data on

  45. 1:25

    that node now a user might want to

  46. 1:27

    follow another user which can be

  47. 1:28

    represented with a relationship inside

  48. 1:30

    of brackets then notice how the arrow

  49. 1:32

    points to another node with a label of

  50. 1:34

    user and that's all it takes to create

  51. 1:36

    relational data no foreign keys or join

  52. 1:38

    tables required although we can add

  53. 1:40

    constraints to the schema such as the

  54. 1:42

    one here that will ensure every username

  55. 1:44

    is unique in addition we can define

  56. 1:45

    local variables in this query then

  57. 1:47

    return them from the statement to get

  58. 1:49

    the data back as the result and what's

  59. 1:50

    especially awesome is that we can

  60. 1:52

    visualize it as an interactive graph or

  61. 1:54

    even as a table now to continue building

  62. 1:56

    Twitter we can connect multiple tweet

  63. 1:57

    nodes to a user we also need a query

  64. 1:59

    that will return all the tweets from all