Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Starting with Graph Databases: A Quick look in ...

Starting with Graph Databases: A Quick look in Neo4j

Natam Oliveira

Cheesecake Labs

November 26, 2018
Tweet

More Decks by Cheesecake Labs

Other Decks in Programming

Transcript

  1. Starting with Graph Databases A Quick look in Neo4j Let's

    talk about this technology, which although recent has already achieved a good percentage of fans. My goal is for you to have a brief (I promise to be quick) vision of how it works.
  2. Very simply, a graph database is a database designed to

    treat the relationships between data as equally important to the data itself. It is intended to hold data without constricting it to a pre-defined model. Instead, the data is stored like we first draw it out – showing how each individual entity connects with or is related to others. Graph Database?
  3. We are used to write data to tables, and to

    relate them through primary keys, looking directly at the data, you see only IDs. The banks in graph were born mainly so that this does not happen, its purpose is that you have complete understanding when looking at the data.
  4. With this we have the database in graphs, a more

    natural way of storing the data, without tables, without foreign keys, only two concepts, nodes and relations, each node or relation can have its attributes and labels of identification, a way to categorize the data. How would a diagram represent this? In graph database? Simpler than you think! Just draw! Natural Way
  5. And this is also true for the "SQL" which in

    the specific case of Neo4j is the Cypher, where its reading and understanding are fundamental and created for this purpose. Cypher
  6. Sintax Creating our first nodes. CREATE (user1:Person:Student { name: "Natam"

    }) CREATE (user2:Person:Teacher { name: "Natalia" }) CREATE (course:Course { title: "Math" }) Now let's relate them. MATCH (s:Student {name:"Natam"}), (t:Teacher {name:"Natalia"}), (c:Course {title:"Math"}) CREATE (s)-[k:KNOWS]->(t), (t)-[ts:TEACHES]->(c), (s)-[e:ENROLLED]->(c) Now that we have our data, we need to consult them, let's do this? MATCH (n) RETURN n
  7. Solving a Rubik’s pocket cube with a graph database A

    pocket cube can have 3 674 160 different positions. For a “No-SQL” database, it’s a piece of cake. Use Case