As the world becomes more connected, so does its data. The data-management tools and techniques of the past are not equipped to handle this non-uniform, semi-structured and highly interconnected data. Faced with this dilemma, software professionals have the option of struggling to fit everything into relational or key-value models, or instead to embrace the graph data model and steer their teams toward success.
It’s not always an easy decision to throw away decades of experience and replace relational databases altogether, but it is straightforward to move the highly connected parts of the system to a graph database. The size and complexity of the data is inevitably fueling a movement toward polyglot persistence (data housed in the stores best equipped to handle it) instead of a single (relational) database. While polyglot requires a broader understanding of data issues, it yields tremendous benefits for data architecture and governance.
To put the drivers for graph database adoption into context, we see that valuable data is generated by the spread of social networks outside their walled garden and into the rest of the Web. The social graph, which entangles the intent, interest and consumption graphs, is driving online commerce and advertisement. Furthermore, the latest advancements in smartphones have rapidly grown the mobile graph tying the online world back to the real. The data generated is already in graph form as people friend each other, like, want, and buy things, and check in to places. In other words, they are creating relationships, the very thing graph databases excel at.
Graph databases have a simple structure, using just two types of objects: nodes and relationships. Users, things and places are modeled as nodes, and various kinds of labeled, directed relationships are created between them (for example, when friend requests are accepted, or things are bought). These simple structures form paths that can then be easily used to compute which of your friends should also be friends, or what new music your friends are buying or what books they’ve recently liked. The data is connected in simple ways, but traversals of these connections can answer very sophisticated questions.
We can query highly connected data using tailored graph query languages that are designed to express intent over graph structures. A graph query language is much simpler than trying to describe such connections with hundreds of lines of SQL code (even with syntactic sugar like Oracle’s CONNECT AS). Finding how things are connected reaches out beyond basic social graphing and into areas like matching people to jobs based on skills and experience, patients to diseases based on symptoms, suspects to crimes, sellers to prospects, borrowers to lenders, etc. One benefit of graph databases is being able to solve problems by matching patterns in a graph.
Another benefit is speed of development. The schemaless nature of graph databases enables developers to rapidly evolve a system as requirements change to align with business needs. Adding a new type of node or relationship is typically painless, and it’s a more natural modeling approach than creating a bunch of join tables and the logic to handle them.
In terms of modeling approach, graph databases are whiteboard-friendly, since business experts can communicate with developers by simply drawing nodes and relationships, which can then be modeled directly in the database, yielding no semantic gap between the user’s data model and how it is expressed in the database. Conversely, with a relational or key-value store, the data model does not resemble the domain (since it is normalized then de-normalized or decomposed into disconnected values). The graph model facilitates the transfer of knowledge from the experts to the developers and business analysts by aligning all stakeholders around the domain.
While some might initially be apprehensive that graph thinking is a new technique to learn, in fact it’s a very natural technique that we simply need to rediscover. But once exposed to graph databases, it’s common to start seeing graphs everywhere, a testament to how natural and powerful the paradigm is.