00:00

What Is a Database?

Last updated: 6 min read

Almost every application you use stores something: your bank keeps account balances, a shopping site keeps products and orders, and a chat app keeps messages. All of that information lives in a database.

This tutorial explains what a database is, how the software that manages it works, why databases replaced plain files, and which parts make up a complete database system. It is the starting point for the rest of the MongoDB tutorial.

1. What Is a Database?

A database is an organized collection of related data, stored electronically so that it can be found, changed and shared easily. "Organized" is the key word: the data follows a structure that a program understands, so it can answer questions like "Which orders were placed today?" in milliseconds, even among millions of records.

A simple everyday example is a phone's contact list. Each contact has the same kinds of details (name, number, email), the list can be searched and sorted, and several apps can read it. A database works the same way, at a much larger scale and with strict rules that keep the data correct and safe.

2. Data vs Information

The two words are often used as if they mean the same thing, but they do not:

DataInformation
Raw facts with no contextData that has been processed and given meaning
42, "Pune", 2026-10-02"42 orders were shipped to Pune on 2 October 2026."
Stored in the databaseProduced by querying and analysing the database

A database stores data; queries, reports and applications turn that data into information people can act on.

3. What Is a DBMS?

You never read or write a database's files directly. Instead, you talk to a Database Management System (DBMS): the software that stores the data on disk, answers queries, and enforces the rules. MySQL, PostgreSQL, Oracle Database, Microsoft SQL Server, SQLite, MongoDB and Redis are all database management systems.

A DBMS is responsible for:

  • Storage: writing data to disk in an efficient format and caching hot data in memory.
  • Querying: understanding requests written in a query language and finding the matching data quickly, often with the help of indexes.
  • Concurrency: letting thousands of users read and write at the same time without corrupting each other's work.
  • Integrity: rejecting invalid data, for example a duplicate email address or an order for a product that does not exist.
  • Security: authenticating users and controlling who may read or change what.
  • Recovery: keeping data safe after crashes and supporting backups and replication.
In everyday speech, people often say "database" when they mean the DBMS, as in "we use MongoDB as our database". That is fine, but it helps to remember that the DBMS is the software and the database is the data it manages.

4. Why Not Just Use Files?

Early programs stored data in ordinary files, and small scripts still do. As soon as data is shared or grows, plain files cause problems that a DBMS was designed to solve:

Problem with plain filesHow a database solves it
Finding one record means reading the whole fileIndexes find records directly, like the index of a book
Two programs writing at once can overwrite each otherLocks and transactions keep concurrent changes safe
The same customer is copied into many files and the copies drift apartData is stored once and referenced or kept consistent by rules
Any program with file access can read everythingUsers, roles and permissions control access
A crash in the middle of a write leaves a half-written fileJournals and transactions make every change complete or not at all
Every program needs its own code to parse the formatA standard query language or API works for every application

5. Components of a Database System

A complete database system is more than the data itself. It has five parts:

  1. Data: the stored records, plus metadata that describes them, such as table definitions, field types and indexes.
  2. Software: the DBMS, its drivers for programming languages, and tools such as shells and graphical clients.
  3. Hardware: the servers, disks, memory and network the DBMS runs on, whether in your own data centre or in the cloud.
  4. Query language or API: the way programs talk to the DBMS, such as SQL for relational databases or the MongoDB Query API for MongoDB.
  5. People: end users, application developers, and database administrators (DBAs) who design, tune, secure and back up the database.

6. A Small Example

Imagine an online bookstore. It needs to remember books, customers and orders. In a relational database, each kind of thing gets its own table, and a query combines them:

SQL: tables and a query
CREATE TABLE books (
  book_id  INT PRIMARY KEY,
  title    VARCHAR(200) NOT NULL,
  price    DECIMAL(8,2) NOT NULL
);

INSERT INTO books VALUES (101, 'Practical Java Streams', 499.00);

-- Which books cost less than 500?
SELECT title, price FROM books WHERE price < 500;

A document database such as MongoDB stores the same book as a self-describing document, without a fixed table definition:

MongoDB document
{
  _id: 101,
  title: "Practical Java Streams",
  price: 499,
  tags: ["java", "streams"]
}

Both are databases. They organize data differently, which is exactly what the next tutorial, Types of Databases, is about.

7. Properties of a Good Database

  • Accurate: rules and constraints stop invalid data from getting in.
  • Consistent: every user sees data that follows the rules, even while others are writing.
  • Durable: once a change is confirmed, it survives power loss and crashes.
  • Fast: common questions are answered in milliseconds through indexing and caching.
  • Secure: only authorized people and programs can see or change data.
  • Scalable: it can grow with more data and more users, on bigger or more machines.

Relational databases describe the first four guarantees for transactions with the acronym ACID: Atomicity, Consistency, Isolation and Durability. MongoDB also provides ACID transactions, including across multiple documents.

8. Where Databases Are Used

AreaWhat the database stores
BankingAccounts, balances, transactions, loan records
E-commerceProduct catalogues, carts, orders, payments, reviews
HealthcarePatient records, appointments, prescriptions
Social mediaProfiles, posts, comments, likes, followers
TransportBookings, schedules, live vehicle locations
IoT and monitoringSensor readings and metrics, often as time series

9. Summary

  • A database is an organized collection of related data stored so that it can be searched, changed and shared easily.
  • A DBMS is the software that manages the database: storage, queries, concurrency, integrity, security and recovery.
  • Databases replaced plain files because files are slow to search, unsafe for concurrent writes, hard to secure and easy to corrupt.
  • A database system combines data, software, hardware, a query language and people.
  • Relational databases use tables; document databases like MongoDB use flexible documents.