Tuesday, February 7, 2017

Graph databases and rapid prototyping (part 1)

In the first part, I'll tell you how I was forced out my comfort zone (SQL Server), and look for alternatives in the graph database space. I choose Neo4j, and I was surprised how easy it was to use, and how productive I became.

Part 1: How I got hooked on graph databases
Part 2: What is a graph database
Part 3: Rapid prototyping

I am very excited to share tremendous experience I had with graph databases (Neo4j specifically), and how going schema-less first (and hybrid or schema-full later) changed my approach to design software. This topic is orthogonal to "NoSQL", the term that holds the second place ("cloud" being the first) in overuse and ambiguity.

For many years, my "to go" (and only) option to do any database work was Microsoft SQL Server. It was easy and natural to open Management Studio and start writing SQL queries. Plus, vast and mature tooling, integration options, language support, community and documentation... you name it.

On my recent project, however, I needed some graph-related functionality (like friends of my friends who liked posts I liked), and I just couldn't get an acceptable performance with SQL Server. I found some 3rd-party solutions on top of SQL Server, that would persist a graph in some way and then reconstruct it in memory for fast traversals. That sounded horrifying, so it was the time for me to take a good look at the graph databases.1


I ended up choosing Neo4j (with OrientDB being a close second2). It was surprisingly easy to do the data modeling and querying. Traversals and finding the shortest path came for free. But my biggest surprise was that I finished all my back-end work in fraction of the time I would expect/estimate. I attribute this fact to the schema-less nature of graph databases (more about this in parts 2 and 3).
"Where have you been all my life"
Looking back at all my previous projects, I would estimate that a graph database would've been a better choice (over a SQL database) in 80% of cases. And, I would always use it for the initial design and prototyping. I do not feel too bad, however, as the graph databases really came to maturation about 3 years ago.

You can find a good description of a graph database on Wikipedia.
2 The ranked list of the most popular graph databases is here.

No comments:

Post a Comment