Deciding On Graphs: Four Questions


Originally Posted on Medium

Take 5 minutes. Ask yourself the four questions listed below. Answer ‘yes’ to at least one of them, and you might want to consider looking into graph databases like Neo4j. While this checklist is by no means exhaustive, it covers some of the lowest common denominators of real Neo4j projects.

Question 1: Will I be evolving this project and data model over time?

Let me guess. You know about the schema migrations that await. Perhaps you’ve experienced the constant updating of unrelated queries and code as your schema changes. The one-off columns that creep into your tables. The heavy data lifting in your application code. You’ve been down this road before. You know exactly where it ends. And I know that’s not where you want to be.

Take the red pill.

Question 2: Am I doing more than one JOIN?

You have no conceptual problem with JOINs. They are, in fact, very logical. But when you ask your database to do several of them, it just doesn’t seem to run as smoothly as it should. When you return to that beautiful query months later, you struggle to remember why the sixth JOIN was a FULL OUTER one. Soon you start dreading making changes to your queries, and you only do it when you have to. You stop pushing the boundaries of your data. You are eyeing the blue pill.

Take the red pill.

Question 3: Will I potentially want to ask other things of this data later?

The schema makes you feel safe. You know what’s in your database. But as the saying goes, you don’t know what you don’t know. Rue the day when you get asked to figure out how these things over here relate to those things over there. Don’t think it will happen? It will. And when it does, you will build a glorious denormalized, pre-computed view of that data. It may be a bit stale, but hey, it works. Before you know it though, you’ll be herding static views like they were cats, i.e. not at all. You know what to do, right?

Take the red pill.

Question 4: Do I feel inclined to draw the graph on a whiteboard?

This is actually my favorite question. The human brain’s urge to look for patterns in information is exceptionally strong. Put a human in front of a whiteboard with a pen, give them a problem to solve, and they will draw something — I guarantee it. What if your application and domain design worked exactly like a whiteboard? Wouldn’t that be something?

Take the red pill.

Want to learn more about graph databases? Click below to get your free copy of O’Reilly’s Graph Databases ebook and discover how to use graph technologies for your application today. Download My Ebook