Neo4j: First Impressions

In my time as a web developer I have only had experience with SQL databases. From Postgres to SQLite, but always a steady, constant, SQL. SQL!! SQL!!!!

Excuse me for that. Anyways, as I was saying, I recently decided to branch out and begin learning Neo4j.

Neo4j is a graph database. If you don’t know what a graph database is, it’s essentially a way to store data that has great benefits for datasets where data points are highly interrelated. The graph database has two types of data, a node and a relationship. A node could be a person, for example, and a relationship between two people nodes could be “friends”. That way when you query for a person’s friends, the graph can easily find the initial nodes and all nodes attached to that initial node via the “friend” relationship.

Kinda neat, right? I thought so too!

This allows for a super flexible database that can be as large or as tiny as you see fit. Compare this to SQL databases that need rigid schema. If not enough forethought was put into the architecture in the beginning or if the requirements change, this could lead to some very ugly refactors with a ton of migrations.

Alongside this, relational databases are often structured by storing primary keys to other records or by adding an entire new table referred to as a join table. This quickly becomes computationally intensive as many different ids need to be looked up. Compare this to a graph database where we can just find the shortest path between nodes via their relationships.

In sum, I believe everyone should give a graph database, and specifically Neo4j, a shot. Not only is it very easy to understand its core concepts, the community seems to be very healthy and bustling, with many of the questions that first arose in my usage being quickly solved via concise searches on the web. That being said, the community is not nearly as robust as say the Postgres community is… for now. Graph databases provide a very dynamic way of storing data while remaining super flexible, which is a much better way to approach a lot of storage problems in this day and age.

I am excited to keep using Neo4j to expedite my growth and domain expertise in order to more fully understand the types of storage problems it and other graph databases can help us solve.