EVENTYou’re invited to MongoDB.local NYC on May 2. Use code Web50 for 50% off your ticket! Learn more >

A database is a software component that’s critical in almost every modern application. There are myriad databases in use, and their number keeps growing. Understanding the major types of databases will help you choose the one that’s right for you.

In this article, we’ll use the terms “database” and “database management systems” (DBMS: software that enables users to access data, and interact with a database) interchangeably.


TABLE OF CONTENTS

What Is a Database?

A database management system is a software to store, organize, manage, and retrieve data. Think of it like a group of massive spreadsheets that organize information. There's more than one type of database management system, and each is housed on servers, whether in a data center or virtually, on cloud infrastructure (cloud database).

Database management systems come in a variety of shapes, sizes, and flavors, each designed to do different things with different kinds of data. MongoDB is a general-purpose, document-based, distributed database management system built for modern application developers. We also offer an object oriented database (OOD), Realm.

What type of information is stored in a database?

Databases are used in most modern applications, whether the database is on your personal phone, computer, or the internet. An operational database system will store much of the data an application needs to function, keeping the data organized and allowing users to access the data.

If you were building an eCommerce app, some of the data you might access and store in your operational database system includes:

  • Customer data, like usernames, email addresses, and preferences.

  • Business data, like product colors, prices, and ratings.

  • Relationship data, like the locations of stores with a specific product in stock.

How Many Types of Databases Are There?


There are nearly a dozen types of database. Some of the more commonly used categories of database include:


Hierarchical Databases

Developed in the 1960s, the hierarchical database looks similar to a family tree. A single object (the “parent”) has one or more objects beneath it (the “child”). No child can have more than one parent. In exchange for the rigid and complex navigation of the parent child structure, the hierarchical database offers high performance, as there’s easy access and a quick querying time. The Windows Registry is one example of this system.

Relational Databases

Relational databases are a system designed in the 1970s. This database commonly uses Structured Query Language (SQL) for operations like creating, reading, updating, and deleting (CRUD) data.

This database stores data in discrete tables, which can be joined together by fields known as foreign keys. For example, you might have a User table that contains data about your users, and join the users table to a Purchases table, which contains data about the purchases the users have made. MySQL, Microsoft SQL Server, and Oracle are examples.


Non-Relational Databases

Non-relational management systems are commonly referred to as NoSQL databases. This type of database matured due to increasingly complex modern web applications. These databases' varieties have proliferated over the last decade. Examples include MongoDB and Redis.


Object oriented databases

Object oriented databases store and manage objects on a database server's disk. Object oriented databases are unique because associations between objects can persist. This means that object oriented programming and the querying of data across complex relationships is fast and powerful. One example of an object oriented database is MongoDB Realm, where the query language constructs native objects through your chosen SDK. Object oriented programming is the most popular programming paradigm.

All about NoSQL

NoSQL is an umbrella term for any alternative system to traditional SQL databases. Sometimes, when we say NoSQL management systems, we mean any database that doesn't use a relational model. NoSQL databases use a data model that has a different structure than the rows and columns table structure used with RDBMS.

NoSQL databases are different from each other. There are four kinds of this database: document databases, key-value stores, column-oriented databases, and graph databases.

Document databases

A document database stores data in JSON, BSON, or XML documents. Documents in the database can be nested. Particular elements can be indexed for faster querying.

You can access, store, and retrieve documents from your network in a form that is much closer to the data objects used in applications, which means less translation is required to use and access the data in an application. SQL data must often be assembled and disassembled when moving between applications, storage, or more than one network.

Document databases are popular with developers because they offer the flexibility to rework their document structures as needed to suit their applications. The flexibility of this database speeds development — data becomes like code and is under the control of developers. They can more easily access and use it. In SQL databases, intervention by database administrators may be required to change the structure of a database.

Document databases are usually implemented with a scale-out architecture, providing a path to the scalability of data volumes and traffic. Use cases include eCommerce platforms, trading platforms, and mobile app development.

Comparing MongoDB vs. PostgreSQL offers an analysis of MongoDB, the leading distributed NoSQL database, and PostgreSQL (an open source DBMS). Unlike a centralized database, it exists on multiple databases but presents as one.

Key-value stores

This is the simplest type of NoSQL database. Every element is stored as a key-value pair consisting of an attribute name ("key") and a value. This database is like an RDBMS with two columns: the attribute name (such as "state") and the value (such as "Alaska").

Use cases for NoSQL databases include shopping carts, user preferences, and user profiles.

Column-oriented databases

While an RDBMS stores data in rows and reads it row by row, column-oriented databases are organized as a set of columns. When you want to run analytics on a small number of columns in the network, you can read those columns directly without consuming memory with unwanted data. Columns are of the same type and benefit from more efficient compression, making reads even faster. A column-oriented database can aggregate the value of a given column (adding up sales for the year, for example). Use cases of a column-oriented database include analytics.

While column-oriented databases are great for analytics, the way they write data makes it difficult for them to be consistent as writes of all the columns in the column-oriented database require multiple write events on disk. Relational databases don't suffer from this problem as row data is written contiguously to disk.

Graph databases

A graph database focuses on the relationship between data elements. Each element is contained as a node. The connections between elements in the database are called links or relationships. Connections are first-class elements of the database, stored directly.

A graph database is optimized to capture and search the connections between elements, overcoming the overhead associated with JOINing several tables in SQL. Very few real-world business systems can survive solely on graph databases. As a result, graph databases are usually run alongside more traditional databases.

Use cases include fraud detection and social networks.

These databases are diverse in their data formats and applications. Furthermore, systems store data in different ways:

  • Data can be stored in a structured document, similar to JSON (JavaScript Object Notation). MongoDB is a popular document distributed database.

  • Data can be in a key-value format that maps a single attribute (key) to its value. Redis and Riak KV are examples. They’re typically used for simple one-to-one relationships, like associating users with preferences.

  • A graph datastore uses nodes to represent objects and edges to describe the relationship between them. Neo4j is one example.

These differ from RDBMS in that they can be schema-agnostic, allowing unstructured and semi-structured data in a network to be stored and processed.

Relational database vs non-relational

When should you use a NoSQL database? Different kinds of databases have different strengths and weaknesses. Since RDBMS systems are popular, it's worth exploring what advantages a non-relational database like a NoSQL database has over them. (Learn more about the differences between RDBMS and NoSQL databases.)

RDBMS pros:

  • They're ubiquitous, having acquired a steady user base since the 1970s.

  • They're optimized for working with structured data.

  • They provide a stronger guarantee of data normalization.

  • They use a well-known querying language, SQL.

The relational database network has emerged as a compelling alternative as it boasts the following advantages:

  • A relational database is more flexible and easier to manage. Many RDBMSs cannot easily work with semi- and unstructured data. For analytics, IoT payloads, and evolving application needs, RDBMSs' adherence to a strict schema makes them inflexible. Plus, the scale of traffic and the need for zero downtime cannot be handled by SQL.

  • The database is fault-tolerant, and data is eventually consistent (though it can vary based on the configuration settings of each database).

  • A NoSQL database is highly performant for large sets of data and better at scaling to meet demands. RDBMSs aren't typically designed for horizontal scale and can suffer under a massive amount of data. The amounts of data in applications cannot be served as affordably as they can in NoSQL databases.

Cost of data over time image with green plot points.

Learn more about the differences between these two database types.


visualization of the distinction between relational vs non-relational databases.

How is MongoDB different from other types of databases?

MongoDB is a NoSQL distributed database program. Because data doesn’t need to fit within the confines of a strict relationship, MongoDB can operate as a general data store. This database provides several advantages.

In this type of database, data is stored in MongoDB and maps to a flexible schema. If your application’s needs change, you can restructure how your data is stored. Since MongoDB provides schema validation, you can lock down your schema as much or as little as you'd like. This means that the database can handle whatever your data structuring needs might be.

In a relational database, relationships between data in different tables can be achieved through joins, and within hierarchical databases, relationships across nodes are impossible. MongoDB provides the ability to join documents through operations that match a variety of needs, such as $lookup, as well as through references.

Additionally, unlike a centralized database (or a personal database, for that matter), MongoDB doesn't have a single point of failure.

Lastly, MongoDB supports transactions, which guarantees the atomicity of reads and writes to multiple documents. When you need to query data from multiple documents, you know that the queries can be combined into a single transaction.

MongoDB was designed to support applications in the internet age, where users can manipulate data from any number of places. Its out-of-the-box support for replication, load balancing, and aggregation makes it a versatile part of modern software architecture. It can offer schema suggestions to help you make choices that optimize for MongoDB’s distributed database/document data model.

Read more about some of the advantages of using MongoDB, a NoSQL database.


What Are the Advantages of MongoDB Atlas?

MongoDB Atlas is a multi-cloud document database service. It’s an on-demand fully managed service run by a team of MongoDB sysadmins, so that you can focus on what matters: your own application. MongoDB Atlas database hosting is available on various cloud providers, such as AWS, Microsoft Azure, and Google Cloud Platform, which ensures that it can serve your needs no matter where you are.

An image showing the creation of an instance in MongoDB Atlas.

MongoDB Atlas database hosting is available on various cloud providers, such as AWS (Amazon's cloud), Microsoft Azure cloud, and Google Cloud Platform.


An image of public cloud providers: Microsoft Azure, AWS, and Google Cloud Platform.

Conclusion

There are many different types of database available, and each has advantages and disadvantages. Before deciding which database is right for you, it’s crucial to get a broad understanding of how your data relates to your application, and how you anticipate your data and application procedures to evolve.

Using MongoDB (a distributed database) satisfies the needs of both a traditional, structured data set and a dataset that requires a flexible schema to allow for changing application procedures.

Ready to get started?

Get your free cloud database with MongoDB Atlas.

FAQs

What are the three main types of database?

There are three different types of databases: hierarchical, relational, and non-relational. Others include the object oriented database, personal database, and centralized database.

How is MongoDB different from other types of database?

MongoDB is a NoSQL distributed database that stores data as BSON documents. BSON is a binary representation of JSON (JavaScript Object Notation). The document model grants it the ability to store data that adheres to a user-defined format while being flexible enough to evolve as an application’s needs change.

How many different types of relationships exist in database designing?

Data can have one of three different types of relationships: one-to-one, where one record matches another record; one-to-many, where one record can match with any number of other records; and many-to-many, where more than one record can have relationships with each other.
Relational databases are more common among the different types of databases. However, the popularity of the non-relational database is on the rise. The type of database you choose depends on your needs and goals.

What type of consistency do relational databases provide?

They typically provide strong consistency, also known as immediate consistency. Non-relational typically provides eventual consistency.

What are the four most common types of NoSQL databases?

The four categories are key-value databases, document databases, wide-column stores, and graph databases.