Skip to main content

Graph databases, explained.

Published 2021/11/10 12:25

Suppose you have a bunch of phone numbers from all of your friends.

You want a way to store these numbers so you can easily find them whenever you want on your computer.

Since you know about databases, you decide to make an SQL database and store the phone numbers there.

That’s great! Now you have a place where you can store your friends’ phone numbers!

Now, you decide to store your friends' parents' phone numbers as well.

Just in case you forget, you decide to label the new numbers as your friends' parents.

How would you do that?

If your answer is to create a ”relationships” table and work with that, then yes, that would be the relational way of tackling this problem.

However, this seems to overcomplicate stuff. What if there was a different type of database, not dependent on SQL, that is specifically designed to store relationships between entries?

There is:

Enter GRAPH DATABASES

Graph databases are basically databases, just like any other, but instead of tables, the entries are connected by their relationships.

For example, you can store the names of your friends:

But now you can join them together and put a label.

And you can obviously include everyone's phone numbers as well:

This way of storing relationships is such more clear and makes much more sense than just storing these in a relational database! Right?

So how do I get started?

One such database is called Neo4J. It is a graph database based on a language called Cypher.

Here’s how it works:

The Cypher code below, firstly creates the two entries for Alice and Frank and then binds them together by their relationship:

CREATE (frank:Person {name: “Frank”, phone: “989522577”})
CREATE (alice:Person {name: “Alice”, phone: “519198724”})

CREATE (frank)-[:IS_PARENT_OF]->(alice)

And this, in very general terms, is how graph databases work!

Dev, Explained (43 part series)

  1. Javascript Scopes, explained.
  2. Javascript Promises, explained.
  3. Accessibility, explained.
  4. React, explained
  5. Should I use forEach() or map()?
  6. Should I use Flexbox or CSS Grid?
  7. Docker, explained.
  8. Unit testing, explained
  9. Git, explained.
  10. Typescript, explained.
  11. async/await, explained.
  12. The DOM, explained.
  13. Regular expressions, explained
  14. GraphQL, explained.
  15. Vue, explained.
  16. Svelte, explained.
  17. API, explained.
  18. Javascript Hoisting, explained.
  19. Immediately Invoked Function Expressions (IIFE), explained.
  20. ARIA roles, explained.
  21. Test-driven Development, explained.
  22. ARIA live regions, explained.
  23. aria-label in accessibility, explained.
  24. Type coercion in Javascript, explained.
  25. Variables, explained.
  26. if statements, explained.
  27. Arrays, explained.
  28. Currying in Javascript, explained.
  29. Memoization, explained.
  30. For loops, explained.
  31. Javascript Prototypes, explained.
  32. React Hooks, explained.
  33. Graph databases, explained.
  34. MongoDB, explained.
  35. Serverless, explained.
  36. Javascript Callback functions, explained.
  37. HTML, explained.
  38. CSS, explained.
  39. Responsive design, explained.
  40. Javascript, explained.
  41. The CSS Box Model, explained.
  42. CSS Flexbox, explained.
  43. CSS Grid, explained.
2022 Savvas Stephanides
Buy me a coffee
Some icons from Freepik