Database
- In Turkish
- Veritabanı
In short
A database is an organized collection of data stored on a computer, managed by software that lets applications save, search, and update it efficiently.
What is a database?
A database stores information in a structured way so it can be found and changed quickly and safely, even when there are millions of records and many users at once. Almost every application, from a to-do list to a bank, keeps its data in a database instead of in loose files.
The software that runs a database is called a database management system (DBMS), such as PostgreSQL, MySQL, SQLite, MongoDB, or Redis. Applications talk to the DBMS by sending queries, and the DBMS takes care of storing data on disk, building indexes for fast lookups, controlling access, and keeping data consistent when many changes happen at the same time.
Databases come in two broad families. Relational databases store data in tables with rows and columns and are queried with SQL, while NoSQL databases use other models such as documents, key-value pairs, wide columns, or graphs. A relational database is a bit like a set of linked spreadsheets with strict rules about what each column may contain.
People often say database when they mean the DBMS software, or the other way around. Strictly, the database is the data itself and the DBMS is the program that manages it. A database also differs from a spreadsheet: it is built for many simultaneous users, large volumes of data, enforced data rules, and access from code.
At a glance
Key takeaways
- A database stores data so applications can save and retrieve it reliably.
- A DBMS such as PostgreSQL or MongoDB is the software that manages the data.
- Relational databases use tables and SQL; NoSQL databases use other data models.
- Databases handle concurrent access, consistency, security, and backups.
Example
-- Create a table to store users
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE
);
-- Save a record
INSERT INTO users (id, name, email) VALUES (1, 'Ada', 'ada@example.com');
-- Find it again
SELECT name, email FROM users WHERE id = 1;Readers ask
What is the difference between a database and a DBMS?
The database is the organized data itself, while the DBMS (database management system) is the software, such as MySQL or PostgreSQL, that stores, queries, and protects that data.
What is the difference between a database and a spreadsheet?
A spreadsheet is designed for a person to view and calculate on a fairly small amount of data. A database is designed for applications and many users to store and query large amounts of data safely, with rules that keep the data consistent.
What are the main types of databases?
The two main families are relational (SQL) databases, which store data in tables, and NoSQL databases, which include document, key-value, wide-column, and graph databases.
See also
- SQLDatabases, p. 40SQL is the standard language for working with relational databases, used to create tables and to insert, query, update, and delete the data stored in them.
- NoSQLDatabases, p. 29NoSQL is a family of databases that store data in models other than relational tables, such as documents, key-value pairs, wide columns, or graphs.
- ORMDatabases, p. 33An ORM is a library that maps database tables to objects in your programming language, letting you read and write data with code instead of raw SQL.
- Database IndexDatabases, p. 7A database index is a data structure that helps a database find rows quickly without scanning a whole table, much like the index at the back of a book.
- TransactionDatabases, p. 47A transaction is a group of database operations that succeed or fail as a single unit, so the data is never left in a half-finished, inconsistent state.
- Primary KeyDatabases, p. 36A primary key is a column, or set of columns, whose value uniquely identifies each row in a database table and can never be empty or duplicated.
Spotted a mistake or something missing on this page?Suggest an edit