Don't Use MongoDB For The Wrong Things

The early phases of a greenfield project always seem to conjure up grand ideas of how to use the hottest new technologies to accomplish your goals. Many times, these grandiose plans give way to a more level-headed design discussion where more realistic technologies are adopted. However, there are a few times where the developer with the idea to use the hottest new technology is the one in charge, and ends up getting his way.

Unfortunately, this seems to happen too often in the NoSQL vs RDMS wars. It seems many of the proponents of a NoSQL solution seem to think that you can use your favorite NoSQL datastore, say MongoDB, as a replacement for a relational database. Granted, there are many situations where MongoDB would be an adequate solution for your project and where a relational database would be overkill. However, these scenarios are a lot less common than many seem to think.

Don’t try to innovate with the platform you are building your solution with, innovate with your solution.

When working with a NoSQL solution such as MongoDB, the danger lies in trying to use MongoDB in a project that has an immense amount of related data. While it may seem like a CMS would be a perfect situation to utilize MongoDB, in reality, there are quite a few relationships that exist in even the most basic of websites. Many times, pages are grouped into categories, and then further grouped by date and/or author. It may seem trivial to just add this information to the document that is stored for each page, but if you need to update the author’s name on all of the posts that they wrote because they had a change in their legal name, it would take some work to update each page’s document. If, however, you wanted to show all of the pages that a single author contributed to, you can still do it in MongoDB, but it just adds another level of relationship to data that is supposed to not be relational.

The scenario that you absolutely do not want to use MongoDB is when you are working with financial or other multi-part transactions that must either go all the way through to completion or return an error and save no history of the transaction’s effects on the data moving forward. An eCommerce platform would be a perfect example of when you absolutely want transactions to complete for an entire sales order instead of partial completions. A partially complete sales order would cause developers many lost hours trying to figure out which customer tried to order which product and with which payment method that got lost. Relational database systems provide a standardized method for doing this, allowing developers to base their designs on industry best practices.

While there are valid use cases for MongoDB and other NoSQL database stores, they are not the right choice for many projects. Don’t try to innovate with the platform you are building your solution with, innovate with your solution.

Related Posts

Jul 11, 2014
3 minutes

Estimating Software Development Projects is Hard

As a software developer, working with non-technical management and end users to define a deadline for when a project will be ready to use or how long it will take from start to end of a project is an extremely complex task. Unfortunately, the non-technical audience thinks that it should be simple to give some sort of estimation on the fly without detailed analysis of the project and what it involves, as it seems simple for them to estimate tasks that are like ones they have done before.

Jan 5, 2015
3 minutes

Let's talk about equality

Equality has been a major topic of discussion over the last few weeks. Whenever this topic comes up, I am always suprised how limited many people’s knowledge about true equality is. Relax everyone, I am talking about equality operators in JavaScript, and not the topic of national discussion recently.

Thinking back to some interviews I have been a part of recently, it became extremely obvious how little most Front End Web Developers know about the JavaScript equaltiy operators. You got that right, I said “operators” because there are two operators that test for equality between two objects, == and ===.

Apr 1, 2015
2 minutes

Using The Ampersand With Compass

While much of working with Compass to generate the CSS for your site is straightforward, there are a few ways to use Compass the provide great power, but are not as easy to understand at first glance. This article discusses one such way, hopefully making it easier to understand.

The operator that we will be looking at first is the & operator. The & as part of a selector in Compass allows you to take the entire selector string at a higher nesting level than the & currently resides upon, and replace the & with that selector string. Typically, when this precedes a selector with a space between the & and the selector, it would operate normally as if the & were not present. However, if you remove the space, it allows you to select elements with multiple classes assigned to them as part of a single selector token.