Menu
Coddy logo textTech

What Is a Database?

A database is an organized collection of data stored on a computer so that programs can find, add, change and delete it quickly and safely. It is managed by software called a database management system (DBMS), such as PostgreSQL, MySQL, SQLite or MongoDB.

By Kevin Spektor, Co-founder & CTO

Updated September 24, 2026

When you sign in to a website, the site has to find your account among millions of others, check your password and load your settings, all in a few milliseconds. It does not open a text file and read it line by line. It sends a request such as SELECT * FROM users WHERE email = 'ana@example.com' to a database, and the database jumps straight to the right row using an index, much like the index at the back of a book.

How a database works

Two pieces work together. The database is the data, organized in a fixed structure. The database management system (DBMS) is the program that stores that data in files, keeps it consistent, and answers requests. PostgreSQL, MySQL and SQLite are DBMSs; your list of customers is the database.

In a relational database, data lives in tables. Each table has columns (name, country, points) and rows (one per user). A request goes through these steps:

  1. Your program sends a query, usually written in SQL (Structured Query Language).
  2. The DBMS parses the query and plans how to answer it: which tables to read and whether an index can skip most of the rows.
  3. It reads the data from disk in fixed-size pages (4,096 bytes by default in SQLite, 8 KB in PostgreSQL), keeping frequently used pages in memory.
  4. It filters, sorts and combines rows, then returns the result.

Python ships with SQLite, so you can run a real database right here:

Kenji 340
Omar 340
Ana 120
users: 4 average points: 222.5

The program never says how to search. It describes the result it wants, and the DBMS decides how to get it. That is the main difference between asking a database and writing a loop over a list.

Types of databases

TypeStores data asExamplesTypical use
Relational (SQL)Tables of rows and columns, linked by keysPostgreSQL, MySQL, SQLite, Oracle, SQL ServerUsers, orders, payments: most applications
DocumentJSON-like documentsMongoDB, Firestore, CouchDBRecords whose fields vary from one to the next
Key-valueA value looked up by one keyRedis, DynamoDBCaches, sessions, counters
Wide-columnRows with flexible columns spread over many serversCassandra, HBaseVery high write volumes
GraphNodes and the relationships between themNeo4jSocial networks, recommendations
Time-seriesMeasurements indexed by timeInfluxDB, TimescaleDBMetrics, sensor readings
VectorLists of numbers (embeddings)pgvector, Pinecone, MilvusSimilarity search for AI features

Everything that is not relational is often grouped as NoSQL. Relational databases remain the default choice for most applications, because tables, constraints and SQL cover a wide range of problems well. Many products also combine types: PostgreSQL stores JSON documents, and pgvector adds vector search to it.

Transactions: all or nothing

Moving money from Ana to Ben takes two changes: add to Ben, subtract from Ana. If the program crashes between them, money appears from nowhere. A transaction groups changes so that either all of them are saved or none are. Here the second change breaks a rule (a balance may not go below zero), so the database undoes the first one too:

transfer 30 done
{'ana': 20, 'ben': 30}
transfer 40 failed: CHECK constraint failed: balance >= 0
{'ana': 20, 'ben': 30}

Ben's 40 was added and then taken back, so the totals still add up. Relational databases promise four properties for transactions, known as ACID: atomic (all or nothing), consistent (rules such as CHECK always hold), isolated (two users running transactions at once do not see each other's half-finished work) and durable (once saved, a change survives a crash or power loss).

Database vs spreadsheet vs file

Text or CSV fileSpreadsheetDatabase
SizeWhat your program can load1,048,576 rows per sheet in ExcelBillions of rows
Many writers at onceNoLimitedYes, with locks and transactions
Finding one recordRead the whole fileFilter or searchIndex lookup
Rules on the dataNoneOptional validationTypes, constraints, foreign keys
Asking questionsWrite your own codeFormulasSQL or a query API

A spreadsheet is a good tool for one person looking at a few thousand rows. Once several programs or users write data at the same time, or the data has to follow rules, a database is the right tool.

How databases protect data

A DBMS writes each change to a log before it touches the data files (the write-ahead log), so after a crash it can replay or undo unfinished work. PostgreSQL can store a checksum on every 8 KB page and report a checksum failure when a failing disk returns damaged data. Users and permissions decide who may read or change which tables, and replication keeps copies on other servers. Programs must also pass user input as parameters, like the ? placeholders above, never by pasting it into the SQL text, which is how SQL injection attacks happen.

Common misconceptions

  • "SQL is a database." SQL is the language. PostgreSQL, MySQL and SQLite are databases that understand it.
  • "NoSQL means no SQL at all." The term is usually read as "not only SQL", and several NoSQL databases have query languages that look like SQL, such as Cassandra's CQL.
  • "A database is always a big server." SQLite is a single file that a program opens directly, with no server at all. It runs inside every Android and iOS phone.
  • "Data in a database is safe forever." A database protects against crashes, not against someone running DELETE by mistake. Backups are still needed.

Where to go next

The SQL course teaches queries from the first SELECT. The SQLite docs cover the next steps: what SQLite is, creating a table, indexes and preventing SQL injection. To see how the data is laid out on disk, read what is a byte, and checksum explains how damaged pages are detected.

Frequently Asked Questions

What is a database in simple words?
A database is a place where a program keeps information so it can find it again quickly. Think of a filing cabinet with a perfect index: you ask for "all orders from last week" and get the answer in milliseconds, even when there are millions of records.
What is an example of a database?
The contacts on your phone are stored in a database: both Android and iOS ship with SQLite. A bank keeps customer accounts in a database such as Oracle or PostgreSQL, and Wikipedia stores its articles in MariaDB. An online store keeps products, customers and orders in related tables.
What are the four types of databases?
There is no official list of four. The four most often named are relational databases (tables and SQL), document databases (JSON-like records), key-value stores (a value looked up by a key) and graph databases (nodes and relationships). Older textbooks also list hierarchical and network databases.
What are the top 5 databases?
Oracle, MySQL, Microsoft SQL Server, PostgreSQL and MongoDB have held the top five places of the DB-Engines popularity ranking for years. Among developers, PostgreSQL has been the most used database in the Stack Overflow Developer Survey since 2023, and SQLite is the most widely deployed, since it ships inside phones and browsers.
What is the difference between a database and a DBMS?
The database is the data itself, organized in tables or documents. The DBMS is the software that stores that data on disk and answers requests for it, such as PostgreSQL or MySQL. People often say "database" for both.
Do I need to learn SQL to use a database?
For relational databases, yes: SQL is how you create tables and ask questions of the data, and its basics take a few days to learn. Many programs use a library that writes SQL for you, but knowing SQL makes it much easier to understand what that library is doing and why a query is slow.
Coddy programming languages illustration

Learn to code with Coddy

GET STARTED