What a database and its storage are
A database management system (DBMS) is the software that controls how data is written, read and protected. The files it manages live on physical storage, such as solid-state drives, hard disks or networked storage arrays. A server is a computer that runs the DBMS and answers requests from other programs.
Storage is usually described in layers. Memory (RAM) is fast but loses its contents when power is cut. Disks are slower but keep data permanently. A DBMS moves data between the two so that frequently used records are quick to reach.
Relational tables and other data models
A relational database stores data in tables made of rows and columns. Each row is one record, and a primary key is a column whose value identifies that row. A foreign key in one table points to the primary key of another, which links the tables. Relational systems are usually queried with SQL.
Other models exist. Document stores keep records as flexible, nested objects. Key-value stores map one identifier to one value. Column stores and graph databases suit other access patterns. The choice depends on how the data will be queried.
A worked example: customers and orders
Suppose a customers table has 3 rows, with customer_id 1, 2 and 3. An orders table has 5 rows, each holding a customer_id and an amount. Customer 1 has two orders of 20 and 30. Customer 2 has one order of 50. Customer 3 has two orders of 10 and 40.
The query SELECT customer_id, SUM(amount) FROM orders GROUP BY customer_id joins nothing but groups the rows. It returns 50 for customer 1 (20 + 30), 50 for customer 2, and 50 for customer 3 (10 + 40). The total across all orders is 20 + 30 + 50 + 10 + 40 = 150, which equals 50 + 50 + 50.
Common misconceptions
A database is not the same as a spreadsheet. A spreadsheet is built for one person editing a grid, while a DBMS handles many users at once and enforces rules on the data. Another mistake is to treat NoSQL as meaning no structure. Those systems still have structure, but it is often defined differently or checked less strictly.
Backups and replication are also confused. Replication copies data to another server continuously, so a deletion or corruption can be copied too. A backup is a separate, dated copy that allows recovery to an earlier point.
Where databases and storage appear in data science
Analysts pull training data and reports from databases using queries. Data pipelines move records from operational databases into a data warehouse, which is a database designed for analysis across large volumes. Raw files such as logs or images often sit in object storage, which holds files as named objects rather than rows.
Transactions keep data consistent. A transaction is a group of operations that either all complete or none do. Many relational systems follow the ACID properties: atomicity, consistency, isolation and durability.
Key terms
- DBMS
- Database management system, the software that stores, retrieves and protects data in a database.
- Primary key
- A column, or set of columns, whose value uniquely identifies each row in a table.
- Foreign key
- A column that refers to the primary key of another table, linking the two.
- SQL
- Structured Query Language, the standard language for querying relational databases.
- Data warehouse
- A database designed for analysis over large amounts of historical data.
- Transaction
- A group of database operations treated as one unit that fully completes or has no effect.
- Object storage
- A storage type that keeps files as named objects, often used for raw or unstructured data.
