This article is primarily intended for people familiar with relational databases.
MongoDB vs RDBMS
MongoDB is a database that has seen great traction the past years. A key element to its success has been the simplicity that permeates the entire product. It’s easy to understand and get started with.
What MongoDB does is simple to explain — put data in; get the same data out. That’s it. To quote a prominent MongoDB case study with MetLife, “if you just want a low-cost simple solution, where you can just get data in and out, just go with MongoDB.”
Let’s consider again why MongoDB has risen to such prominence. It is due to the simplicity of getting data in and out, contrasted with the effort of doing the same thing in a relational database. Before MongoDB, most companies used products like MySQL for these basic CRUD needs, and schema evolution was a constant pain.
You might be thinking, wait a minute, what about the JOINs? You’re right. MongoDB does not allow you to do any JOINs on your data. Since MongoDB only supports reading the same data you once put in, you need to manually pre-JOIN it before inserting it or read everything out and manually post-JOIN it in your application.
Neo4j vs RDBMS
Neo4j is a graph database. According to independent site db-engines.com, as of December 2014 graph databases are by far the fastest growing database segment.
Being a native graph database, Neo4j stores data as entities (nodes) connected by relationships. There are no tables under the hood. Questions can then be asked across those relationships. For example, consider the supply chain data below. Take a minute to study it.
Given this data we can ask, “which suppliers did John Doe get parts from?” And conversely, we can just as easily ask, “which customers received parts from Joe’s Parts, but only the ones where Keely Autos provided the package?” Neo4j can even tell us how John Doe and Keely Autos are connected through the graph. Most importantly, all these questions can be written in minutes and answered in milliseconds, without any changes to the database.
Some readers might say, “but David, I can build this in my relational database too.” I’m sure you can. You might spend a day getting the query and schema right, and your query might run in minutes or more (given 10+ JOINs across a large dataset). Aside from the obvious benefits of time savings and flexibility, the key difference between minutes and milliseconds is that with millisecond response times you can actually build a service that users can consume.
At the end of the day, it comes down to being more nimble than the competition. In essence, Neo4j is about putting data in and getting insights out.
Neo4j vs MongoDB
Because of the NoSQL movement, Neo4j and MongoDB are often lumped together as being similar. I hope it’s clear to you now that this is not at all the case. Neo4j and MongoDB are very different, and while they are often brought in to replace a relational database, the architectures differ markedly.
Most uses of databases involve taking data from one or multiple sources and then doing something new with it, be it building a new service, improving a process, or gaining new insights.
The MongoDB approach is to act only as final storage of your results. In order to produce those results, you need to do the heavy lifting outside of MongoDB. This may involve merging multiple data sources and producing a tailored output representation. If you want to look at your data from a different point of view, you need to redo the heavy lifting and insert it into MongoDB again.
The Neo4j approach is to cover both unprocessed data and results. A good way of explaining it is by thinking of a whiteboard. Imagine you could draw how your data fits together, such as the supply chain above. That’s exactly how it will be stored in Neo4j, and you can ask pretty much anything without any heavy lifting. As my friend @akollegger once said, “the graph embodies multiple perspectives depending on where you start.”
At this point you may be asking, “Wait a minute. I can ask anything in real time? What’s the catch?” Largely, there is no catch, and that’s why companies like eBay, HP, Cisco, Medium(!), Walmart, Johnson & Johnson, TechCrunch, and countless others rely on Neo4j to build competitive services and learn things that their competition is not learning. I guarantee you will find Neo4j providing great value to your business.
Disclaimer: I work for Neo Technology, the company behind Neo4j, the leading graph database.
Also read my article on dark data, and why you should look into it before big data.