Pinterest Stumbleupon Whatsapp
Ads by Google

Anyone who has ever worked with databases that organize data into tables, also called relational databases, can probably speak at length about its flaws. As great a system for storing data it may be, it is not without its issues and is not designed for interpretation by people, making organizing with it convoluted, redundant, and with a steep learning curve.

Hence, the NoSQL movement. SQL stands for Structured Query Language, and it is used to communicate with databases. But it isn’t that great on a larger scale. When, for example, apps go viral, support is needed so the users can use the app without experiencing any issues. But SQL gets complicated at this scale, more so than many developers can handle.

NoSQL makes storing and organizing data easier, because proponents of the NoSQL school of thought strived to make a database that worked with large data sets, scaled, and was organized like the way people think, and could be easily read by humans. MongoDB is one such database, and it’s changing the way developers build websites.

What is MongoDB?

Connection_to_the_MongoDB_Shell

MongoDB (from “humongous”) is a cross-platform document-oriented database used as an alternative to MySQL. But what does that mean? Well, a database is a structured set of data So What Is a Database, Anyway? [MakeUseOf Explains] So What Is a Database, Anyway? [MakeUseOf Explains] For a programmer or a technology enthusiast, the concept of a database is something that can really be taken for granted. However, for many people the concept of a database itself is a bit foreign.... Read More , however MongoDB differs in that it tends to be less strict about how that data is structured. Information is grouped together, rather than broken down into related documents and tables like MySQL, a popular RDBMS, or relational database management system, that does use SQL.

Many databases that use SQL store data in tables on pages. Think of something like an Excel spreadsheet with bits of code. These pages are the smallest pieces of data on a server, and each page is devoted to one table. This gets convoluted at the large scale, whereas with MongoDB, the developer can decide how to structure the information for whatever suits their needs.

Ads by Google

MongoDB uses BSON to store information. BSON (a combination of “binary” and “JSON”, or JavaScript Object Notation) can be thought of as a binary or numerical representation of JSON documents. JSON What Is JSON? A Layman's Overview What Is JSON? A Layman's Overview Whether you plan to be a web developer or not, it's a good idea to at least know what is JSON, why it's important, and why it's used all around the web. Read More is an open-standard format (like open-source) for organizing data.

It also adds support for certain data types that aren’t supported in JSON, like the data type ‘date’, which wouldn’t normally be supported and therefore could not be used by the developer. The developer, in this case, wouldn’t be able to include any sort of date as a piece of data.

Typically, this data is organized into documents. JSON transmits data using documents that can be easily read by humans, however this is not the case with BSON. JSON is also commonly used to transmit data between a server and application, as well as a general data storage medium.

Documents do not need to be structured in a specific way according to the collection, or a group of related objects they’re organized in, making it very easy for a developer to get up and running with MongoDB. This has lead to it being one of the most popular NoSQL databases out there.

What Makes It Different From MySQL?

Mysql-screenshot

With MySQL being perhaps the most widely used RDBMS out there, although flawed as it may be, it’s only natural that alternatives would crop up. With NoSQL being an alternative to SQL, MongoDB is considered an alternative to MySQL. MySQL uses tables to organize its data and is based off the classic relational data model from the twentieth century, although, like MongoDB, it can be modified for improved functionality.

However, the two differ greatly. They’re intended for different purposes, for one. MongoDB is intended more for the larger (very large) scale whereas there’s only so much that MySQL can handle. As was mentioned before, MySQL uses tables to organize data which can end up very convoluted. However, they are both very good systems, and in fact, hybrids are being implemented on certain sites around the web. Craigslist is known for being one of the more successful websites implementing a MongoDB/MySQL hybrid.

How Does It Work?

mongodb document

MongoDB works by storing data in documents similar to JSON. These documents have one or more fields (objects or values contained within a class or structure) which include arrays (a series of objects all the same size and type) and sub-documents (a document that makes up part of a larger document). These fields can be set as the developer so wishes, according to their needs.

While organizing this would normally be a complicated affair, BSON makes it easy by simply grouping the documents together according to type and size rather than breaking them down into very small pieces of data like SQL does and organizing the data based on other information. Because of this flexibility, developers are able to evolve the collection of data, also called the data model, to suit their needs.

Developers can access the documents through drivers that they are able to read and understand, and the documents are available in most popular, modern programming languages. With MongoDB, the documents are mapped naturally to the objects so there’s no need for an ORM (object-relational mapping) layer that manually maps documents to their respective objects. Simply put, the documents are connected to the objects naturally, so there’s no need for a separate command or program to connect them.

MongoDB uses a JavaScript-based shell, and supports developers writing custom code using JavaScript functions, and will likely become more widespread as JavaScript continues to boom What is JavaScript, And Can the Internet Exist Without It? What is JavaScript, And Can the Internet Exist Without It? JavaScript is one of those things many take for granted. Everybody uses it. Read More in popularity.

Who Uses It?

Although still relatively young, MongoDB is used in a number of popular websites. These include business journal Forbes, as well as gif-tastic Buzzfeed.

Forbes took advantage of MongoDB to rapidly develop a new web and mobile portfolio. The speed and power of MongoDB made it possible for them to set up a website in two months and a mobile app in one month. This had a drastic affect on their reader engagement and traffic. According to the MongoDB developers:

Overnight, mobile traffic jumped from 5% to 15% of Forbes.com total traffic, and quickly ramped to 50%.

Buzzfeed suffers from the challenges any large media organization faces. Their distributed writing staff publish such a prodigious amount of content 5 Websites to Check Out Latest Buzz and Viral Videos 5 Websites to Check Out Latest Buzz and Viral Videos Read More , to a huge audience. MongoDB allows Buzzfeed to rapidly scale according to the traffic they receive, as well as determine what types of content resonates with their readers.

How Do You Use It?

MongoDB is a great tool for web, games and software developers. We know that it’s fast, and scalable. And we know that it’s easy to read, and to learn. But how do you actually use it?

mongodb shell in browser

The official MongoDB website offers users the opportunity to try a MongoDB shell in their browsers. TutorialsPoint offers several very detailed tutorials for using MongoDB, ranging from beginner to advanced. There are also projects on GitHub Not Just for Coders: 9 Ways To Use GitHub For Creative Work Not Just for Coders: 9 Ways To Use GitHub For Creative Work GitHub is known for the great features it can offer programmers, but it's not only for them. There are plenty of other creative uses for GitHub. Here are nine you can explore. Read More related to MongoDB, including The Little MongoDB Book by Karl Seguin, for just about everything you need to know about MongoDB.

If you just want to learn how to install MongoDB, be sure to check out this tutorial from the official MongoDB website.

Should You Use It?

That depends on your individual situation.

As great as MongoDB is, it’s not without its flaws. It’s not ACID compliant. ACID, standing for Atomicity, Consistency, Isolation, and Durability, is a set of properties that ensure that database transactions, or work performed within a database, is processed and completed correctly. NoSQL databases are sometimes not ACID compliant, which does limit their productivity and dependability.

MongoDB also uses all available memory as a system cache. As a result, there are performance issues on computers running on 32-bit systems, which can only address a maximum of 4GB of memory. To learn more about making use of the RAM on your computer, be sure to check out this article by Brad Jones How Much RAM Do You Really Need? How Much RAM Do You Really Need? RAM is like short term memory. The more you multitask, the more you need. Find out how much your computer has, how to get the most out of it, or how to get more. Read More .

Because there is no need for tables with this database, there’s a high risk of developers being lazy and writing sloppy code, however that risk applies to almost anything. You end up with duplicate data, because there is no possibility for joins within the system.

Nevertheless, MongoDB is a blazingly fast, efficient system that can absolutely aid in increasing developer productivity

MongoDB is also user-friendly in that it doesn’t require a unified data structure for all the objects, although it is recommended to set one up for ease of use. The structure of the data doesn’t have to be the same throughout the system, so a singular voice is not completely necessary.

Finally, according to MakeUseOf writer Matthew Hughes Your Startup Should Have A Blog. Here's Why Your Startup Should Have A Blog. Here's Why Here are some more compelling reasons why your startup cannot live without a blog. Read More , the MongoDB team runs an excellent blog, featuring high-quality, well-written technical content aimed at a technical audience.

Conclusion

If you don’t have a system with a good amount of RAM that can’t support a large database, or you’re not really looking to have a large database at all, MongoDB is not for you. It tends to only sell itself when at a large scale. For smaller projects, using RDBMS is probably easier. If, however, you need speed and ease and can support the system, perhaps it’s worth looking into.

Do you have any experience with MongoDB? Curious about trying it out? Leave a comment below and we’ll talk!

Image credits: “Connection to the MongoDB Shell” by Ularugeanina via Wikimedia Commons, “Mysql-screenshot” by Stephantom via Wikimedia Commons

  1. Roberto Andrew
    July 15, 2015 at 6:17 pm

    Recently I discovered a tool simply called DbSchema ( http://www.dbschema.com ). First of all I was impressed because they do diagrams for MongoDB.
    Second I found great an data explorer from them, where you can explore data from each collection and sub-documents in a separate window.

    Now I am dealing with virtual foreign key from them, to explore data from two collections bind referencing one the other via ObjectId's.Look for DbSchema tool, is great for the diagrams they do for MongoDB, query builder and data explorer.Some features you may discover inside like virtual foreign keys makes the interaction really similar with relational databases, where you can place data in multiple collections and join it with ObjectId's.I was surprised to see is possible to have diagrams for MongoDB as well, as for any relational database.

    Go for the tool DbSchema. Have a look on relational data browse and the virtual foreign keys there,
    they are a step forward in designing a database with data over multiple collections and references between them via ObjectId's.

Leave a Reply

Your email address will not be published. Required fields are marked *