A database is a software component that's critical in almost every modern application. There are a myriad of 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.
Key takeaways
Databases store, organize, manage, and retrieve the data that modern applications depend on.
The main types of databases include hierarchical, relational, non-relational, object oriented, document, key-value, column-oriented, and graph.
Relational databases use tables, rows, columns, and structured query language (SQL), making them well suited for structured data and data integrity.
NoSQL databases use more flexible data models, making them useful for unstructured data, semi-structured data, large datasets, and modern web applications.
The right database depends on your data model, scalability needs, performance requirements, and how your application is expected to evolve.
Table of contents
What is a database?
A database management system is software that stores, organizes, manages, and retrieves 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 on a 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.
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 databases. 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 is easy to access and offers quick queries.
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 users table that contains specific data about your users, joined 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 has become popular due to increasingly complex modern web applications. This type of database has 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.
The 4 major families of NoSQL databases
NoSQL is an umbrella term for databases that don’t use the traditional relational model. NoSQL databases use a data model that has a different structure than the rows and columns table structure that’s used with a relational database management system (RDBMS).
There are four major families of this type of database: document databases, key-value stores, column-oriented databases, and graph databases.
1. Document databases
Document databases store data in JSON, BSON, or XML documents. Documents can be nested, and particular elements can be indexed for faster querying.
Unlike SQL data—which must often be assembled and disassembled when moving between applications, storage, or networks—the data in a document database are more similar to the data objects used in applications. These similarities mean less translation is required to use and access application data.
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 is under the control of developers and 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.
Learn more about MongoDB and how it’s different from PostgreSQL — Comparing MongoDB vs. PostgreSQL.
2. 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"). Redis and Riak KV are examples.
They're typically used for simple one-to-one relationships, like associating users with preferences. Use cases for key-value databases include shopping carts, user preferences, and user profiles.
3. 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).
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.
4. 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. In many real-world systems, graph databases are used alongside other databases: a graph engine powers relationship-heavy queries, while a document or relational database handles transactional or operational data. Use cases include fraud detection and social networks. Neo4j is one example.
Relational databases vs. non-relational databases
When should you use a NoSQL database? Different kinds of databases have different strengths and weaknesses. Since RDBMS’s 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 non-relational 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.
Non-relational database pros:
A non-relational database may be more flexible and easier to manage. Many RDBMSs may not easily work with semi-structured and unstructured data, which often makes them less flexible.
Many NoSQL databases are designed for fault tolerance through replication and can be configured for different consistency models, including eventual consistency.
For applications with large, rapidly growing datasets and high throughput requirements, many NoSQL databases are designed to scale out horizontally across commodity hardware, which can make them highly performant and cost-effective at scale. Traditional relational databases can also scale, but typically require more complex architectures and higher-end infrastructure to achieve similar horizontal scale, which can increase cost and operational overhead.
Learn more about the differences between these two database types.
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 type of database provides several advantages.
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 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), when deployed as a replica set across multiple nodes, MongoDB avoids a single point of failure: if one node goes down, another can take over.
MongoDB also supports transactions, which guarantee 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.
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 system administrators, so you can focus on what matters: your own application. MongoDB Atlas database hosting is available on various cloud providers, such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform, which ensures that it can serve your needs no matter where you are.
Read more about some of the advantages of using MongoDB, a NoSQL database.
Choose the right database for your application
Different types of databases solve different problems. Some are built for structured data and strong data integrity. Others are designed for flexible data models, complex relationships, efficient data retrieval, low latency data access, or large datasets that need to scale across distributed environments.
The right database depends on how your application stores, queries, manages, and analyzes data today, as well as how those needs may change over time. For many modern applications, MongoDB provides the flexibility of a document database with the scale, performance, and resilience required for evolving data models and real-world application demands.
Related resources
- Learn the fundamentals of a database management system and how it enables storing, organizing, and retrieving data.
- Explore how document databases work and why they’re widely used in modern application development.
- Understand the structure and use cases of hierarchical databases, one of the earliest database models.
- Dive into object oriented databases and how they align with object-oriented programming concepts.
- Compare relational vs non-relational databases to determine which model fits your application needs.
- See how key-value databases store simple data pairs for fast and efficient access.
- Discover how graph databases model relationships between data for use cases like fraud detection and social networks.
- Review a detailed MongoDB vs PostgreSQL comparison to understand differences between NoSQL and relational approaches.