What Is a Database?
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:
| Data | Information |
|---|---|
| Raw facts with no context | Data 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 database | Produced 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.
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 files | How a database solves it |
|---|---|
| Finding one record means reading the whole file | Indexes find records directly, like the index of a book |
| Two programs writing at once can overwrite each other | Locks and transactions keep concurrent changes safe |
| The same customer is copied into many files and the copies drift apart | Data is stored once and referenced or kept consistent by rules |
| Any program with file access can read everything | Users, roles and permissions control access |
| A crash in the middle of a write leaves a half-written file | Journals and transactions make every change complete or not at all |
| Every program needs its own code to parse the format | A 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:
- Data: the stored records, plus metadata that describes them, such as table definitions, field types and indexes.
- Software: the DBMS, its drivers for programming languages, and tools such as shells and graphical clients.
- Hardware: the servers, disks, memory and network the DBMS runs on, whether in your own data centre or in the cloud.
- Query language or API: the way programs talk to the DBMS, such as SQL for relational databases or the MongoDB Query API for MongoDB.
- 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:
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:
{
_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
| Area | What the database stores |
|---|---|
| Banking | Accounts, balances, transactions, loan records |
| E-commerce | Product catalogues, carts, orders, payments, reviews |
| Healthcare | Patient records, appointments, prescriptions |
| Social media | Profiles, posts, comments, likes, followers |
| Transport | Bookings, schedules, live vehicle locations |
| IoT and monitoring | Sensor 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.