When to move beyond relational databases

 

Connecting state and local government leaders

While RDBMSs will always be robust and powerful, consider document and graph databases to make applications easier to develop and faster to run.

One of my current projects is the review of an application built by a contractor for a major federal agency. The code relies heavily on queries and stored procedures against a relational database management system (RDBMS). These are easily the most complex I have ever seen. Normally when technical debt accrues in a database, IT managers refactor the database design immediately and utilize views, indexes, precomputation and all the other goodies a RDBMS offers.

However, it may very well be that the relational paradigm, as venerable and successful as it is, is simply not the best choice for an application. There are alternative paradigms, notably document and graph databases – colloquially known as NoSQL databases – that have their own advantages and disadvantages. But let’s first  remind ourselves why RDBMSs have dominated for so long before exploring how NoSQL databases compare.

Relational databases

With theoretical foundations in mathematics and powerful commercial and open-source implementations (e.g. Oracle and PostgreSQL respectively), RDBMSs have flourished for decades. They have powerful features we take for granted:

ACID guarantees: Atomicity, consistency, isolation and durability. Atomicity guarantees transactional scope where the failure of any single operation in a set triggers a rollback. Consistency guarantees data is always in a valid state (through referential integrity, for example). Isolation guarantees multiple clients hitting the same data don’t step on each other. Durability guarantees changes persist across catastrophic failures.

SQL: The standard language (with vendor-specific enhancements) for performing database operations. SQL is relatively easy to learn and universally supported.

Ad hoc queries: Queries that have to be run but are never anticipated. Relational databases usually run these quickly.

Commercial support. Available for even open-source options.

Yet RDBMSs aren’t perfect. When the data gets big, they don’t generally scale easily even with sharding. Database schemas are also notoriously rigid in application development. Changes to a single column reverberate among views, stored procedures and application code. Finally, managers need to solve the impedance mismatch between relational data and object-oriented code manually or with potentially complex object-relational mapping technologies like ActiveRecord in Ruby or Hibernate in Java.

Document databases

Sometimes features like ACID can be more trouble than they’re worth. Enter document databases like MongoDB and Apache CouchDB – both open source. “Documents” are flexible binary JSON structures where child records modeled with relationships in a RDBMS are instead embedded within the documents.

Aside from scalability, the biggest advantage is simplicity. Once one becomes familiar with JSON, querying is straightforward. Without a predefined schema, data can evolve as needed. Joins are obviated because data is denormalized. And because JSON is the most common data format on the Web, developers may be able to use a driver to pass data from the database straight through to the front end.

On the other hand, if records embedded in a document change frequently (such that they are  factored out into their own documents in a relational manner), the result may be foreign key relationships without ACID guarantees – meaning possible orphan records. And without joins, it will take multiple queries to fetch the required data. As in RDBMS development, great care is needed in document design and indexing.

Consider document databases when queries can be anticipated or when there is need to scale and/or make relatively few updates to preexisting data. There are support options too – especially for MongoDB.

Graph databases

Anyone who watched The Wire might remember the bulletin board used by the Major Crimes Unit to display an evolving org chart for crime syndicates in Baltimore. The hierarchy was determined through analysis of communications and other data. That was the first graph database I ever saw.

With a graph database, data is modeled as a collection of nodes connected by edges –  both endowed with attributes. As always, the data model must be optimized for the anticipated queries – for example, when deciding whether certain data belongs in a node or edge.

This is a fundamental shift from RDBMSs. When working with network data (such as SIGINT, financial transactions, or migration patterns) modeling in tables and relationships can be awkward. Much worse, RDBMSs can be quite slow for the kinds of queries that matter on graphs like shortest paths, community detection and centrality.

Also built upon a mathematical foundation, graph databases like open-source Neo4J are ideal for storing and querying network data. Though other approaches are available, Cypher, a Neo4J-specific language, is a good choice for querying a graph. It has a steep learning curve, but, in experienced hands, Cypher is a powerful and performant query language.

Like RDBMSs, Neo4J supports ACID transactions and indexing. Commercial support and drivers are available in all major programming languages.

Data is the lifeblood of applications. While RDBMSs will always be robust and powerful and perhaps most familiar, follow the advice of lean software development experts Mary and Tom Poppendieck to consider all options to make applications easier to develop and faster to run.

X
This website uses cookies to enhance user experience and to analyze performance and traffic on our website. We also share information about your use of our site with our social media, advertising and analytics partners. Learn More / Do Not Sell My Personal Information
Accept Cookies
X
Cookie Preferences Cookie List

Do Not Sell My Personal Information

When you visit our website, we store cookies on your browser to collect information. The information collected might relate to you, your preferences or your device, and is mostly used to make the site work as you expect it to and to provide a more personalized web experience. However, you can choose not to allow certain types of cookies, which may impact your experience of the site and the services we are able to offer. Click on the different category headings to find out more and change our default settings according to your preference. You cannot opt-out of our First Party Strictly Necessary Cookies as they are deployed in order to ensure the proper functioning of our website (such as prompting the cookie banner and remembering your settings, to log into your account, to redirect you when you log out, etc.). For more information about the First and Third Party Cookies used please follow this link.

Allow All Cookies

Manage Consent Preferences

Strictly Necessary Cookies - Always Active

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Sale of Personal Data, Targeting & Social Media Cookies

Under the California Consumer Privacy Act, you have the right to opt-out of the sale of your personal information to third parties. These cookies collect information for analytics and to personalize your experience with targeted ads. You may exercise your right to opt out of the sale of personal information by using this toggle switch. If you opt out we will not be able to offer you personalised ads and will not hand over your personal information to any third parties. Additionally, you may contact our legal department for further clarification about your rights as a California consumer by using this Exercise My Rights link

If you have enabled privacy controls on your browser (such as a plugin), we have to take that as a valid request to opt-out. Therefore we would not be able to track your activity through the web. This may affect our ability to personalize ads according to your preferences.

Targeting cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising.

Social media cookies are set by a range of social media services that we have added to the site to enable you to share our content with your friends and networks. They are capable of tracking your browser across other sites and building up a profile of your interests. This may impact the content and messages you see on other websites you visit. If you do not allow these cookies you may not be able to use or see these sharing tools.

If you want to opt out of all of our lead reports and lists, please submit a privacy request at our Do Not Sell page.

Save Settings
Cookie Preferences Cookie List

Cookie List

A cookie is a small piece of data (text file) that a website – when visited by a user – asks your browser to store on your device in order to remember information about you, such as your language preference or login information. Those cookies are set by us and called first-party cookies. We also use third-party cookies – which are cookies from a domain different than the domain of the website you are visiting – for our advertising and marketing efforts. More specifically, we use cookies and other tracking technologies for the following purposes:

Strictly Necessary Cookies

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Functional Cookies

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Performance Cookies

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Sale of Personal Data

We also use cookies to personalize your experience on our websites, including by determining the most relevant content and advertisements to show you, and to monitor site traffic and performance, so that we may improve our websites and your experience. You may opt out of our use of such cookies (and the associated “sale” of your Personal Information) by using this toggle switch. You will still see some advertising, regardless of your selection. Because we do not track you across different devices, browsers and GEMG properties, your selection will take effect only on this browser, this device and this website.

Social Media Cookies

We also use cookies to personalize your experience on our websites, including by determining the most relevant content and advertisements to show you, and to monitor site traffic and performance, so that we may improve our websites and your experience. You may opt out of our use of such cookies (and the associated “sale” of your Personal Information) by using this toggle switch. You will still see some advertising, regardless of your selection. Because we do not track you across different devices, browsers and GEMG properties, your selection will take effect only on this browser, this device and this website.

Targeting Cookies

We also use cookies to personalize your experience on our websites, including by determining the most relevant content and advertisements to show you, and to monitor site traffic and performance, so that we may improve our websites and your experience. You may opt out of our use of such cookies (and the associated “sale” of your Personal Information) by using this toggle switch. You will still see some advertising, regardless of your selection. Because we do not track you across different devices, browsers and GEMG properties, your selection will take effect only on this browser, this device and this website.