Database Systems
What databases and DBMSs are, how data management evolved from flat files to relational and NoSQL, the major relational platforms, OLTP and OLAP workloads, and data warehouses versus data lakes.
What's a database
A database is an organized collection of data, stored so it can be found, updated, and protected easily. Almost every app and service you use runs on one.
In the modern world, data is one of the most valuable things a business owns. Customer accounts, orders, payments, medical records, and flight bookings all live in databases. If the database is slow, the app is slow. If it's down, the business stops. If it's lost, the business may never recover.
A few moments from an ordinary day, each one a database at work:
- Paying with a card. The bank's database checks your balance, records the payment, and updates your account in a fraction of a second.
- Shopping online. The store's database holds every product, price, and stock count, plus your cart and order history.
- Streaming a show. The service remembers where you stopped watching and uses your history to recommend what's next.
- Visiting a doctor. Your medical history, prescriptions, and test results come from the clinic's database.
- Booking a ride. The app stores drivers' locations, your trip, the route, and the fare.
From data to information
Data is raw facts: one row per order, payment, or click. On its own, a single row says very little. Information is what you get when you ask the data a question and get a useful answer, such as "Which product sold the most this month?"
A database stores data in a structured way so it can be queried later: searched, filtered, grouped, and totaled in seconds, even when there are millions of rows.
What's a DBMS
A database management system (DBMS) is the software that creates and manages databases. People and applications never read the data files directly; they send requests to the DBMS, and it does the work.
"Database" and "DBMS" are often used interchangeably in conversation. Strictly speaking, the database is the data, and the DBMS is the software that manages it. Oracle, SQL Server, PostgreSQL, MySQL, and MongoDB are all DBMSs.
From flat files to relational to NoSQL
There are several approaches to storing and managing data. Each one appeared to solve the biggest problem of the approach before it.
- Flat files
- Data is kept in plain files, such as text or CSV files, with one record per line. Each program reads and writes its own files. This was a big step up from paper, but the same data (a customer's name and address, for example) gets copied into many files, the copies drift out of sync, and two people updating the same file at once can corrupt it.
- Relational databases
- In 1970, IBM researcher Edgar F. Codd proposed storing data in tables (relations) made of rows and columns, linked to each other by shared keys. Each fact is stored once, and SQL (Structured Query Language) became the standard way to query it. A relational DBMS (RDBMS) also guarantees safe transactions: a bank transfer either fully happens or doesn't happen at all, even if the server crashes halfway through.
- NoSQL databases
- As web companies grew to millions of users in the 2000s, they needed to store huge amounts of fast-changing data across many cheap servers. NoSQL ("not only SQL") databases relax the strict table structure: they store documents (MongoDB), key-value pairs (Redis), wide columns (Cassandra), or graphs (Neo4j). They scale out easily and handle data whose shape changes often, but usually give up some of the joins and strict consistency that relational databases offer.
Here's the same customer and their orders stored each way:
The major relational platforms
Today, when people say "database", they usually mean a relational database (RDBMS). Four platforms dominate the market:
| Platform | Owner | License | Good to know |
|---|---|---|---|
| Oracle Database | Oracle Corporation | Commercial (proprietary). A free, limited edition, Oracle Database Free, is available for learning and small projects. | The first commercial SQL database, released in 1979. Widely used by large enterprises, banks, and governments. |
| Microsoft SQL Server | Microsoft | Commercial (proprietary). The free Express edition is limited in size, and the free Developer edition is for development and testing only. | Popular with companies that run Microsoft technologies. Runs on Windows and, since 2017, on Linux. Its cloud version is Azure SQL Database. |
| PostgreSQL | The PostgreSQL Global Development Group, a volunteer community; no single company owns it | Open source and free, under the permissive PostgreSQL License. | Grew out of the POSTGRES project at the University of California, Berkeley, which started in 1986. Known for its standards support and extensions, and used by many cloud database services. |
| MySQL | Oracle Corporation (it bought Sun Microsystems, which had bought MySQL AB, in 2010) | Open source: the free Community Edition is under the GPL, and Oracle also sells a paid Enterprise Edition. | A long-time favorite for websites and web apps. MariaDB is a popular open source fork created by MySQL's original developers. |
All four speak SQL, so the core skills carry over. Each has its own tools, features, and SQL extensions, and DBAs often specialize in one or two.
OLTP vs OLAP workloads
Databases do two very different kinds of work, called workloads:
- OLTP (online transaction processing)
- Runs the business. It handles a constant stream of small, fast operations: insert an order, update a balance, look up one customer. Thousands of users can be doing this at the same time, and each operation must finish in milliseconds.
- OLAP (online analytical processing)
- Studies the business. It runs fewer but much larger queries that scan and summarize millions of rows, often across years of history, to answer questions such as "How did sales change this quarter in each region?"
A real-life example
Kofi orders a coffee in a coffee chain's app. In well under a second, the app's OLTP database records the order, charges the card, adds loyalty points, and reduces the store's stock. Thousands of customers are doing the same thing at the same moment.
The company also wants to know which drinks sell best, in which stores, at what time of day. Running those big questions on the OLTP database would slow down the app for customers, so the company copies the data into a separate analytical database called a data warehouse, using a process called ETL.
- Extract
- Pull the new data out of the source systems: orders, payments, the loyalty program, and store lists.
- Transform
- Clean and reshape it: fix errors, remove duplicates, convert currencies, and combine data from different systems into a consistent format.
- Load
- Write the result into the data warehouse, often on a schedule such as every night.
| OLTP | OLAP | |
|---|---|---|
| Purpose | Run day-to-day operations | Analyze trends and support decisions |
| Typical operation | Insert, update, or look up a few rows | Scan and summarize millions of rows |
| Users | Customers and employees, through applications | Analysts, managers, and data scientists |
| Speed that matters | Milliseconds per transaction | Seconds to minutes per query is normal |
| Data | Current, constantly changing | Historical, loaded in batches and rarely changed |
| Design | Normalized: each fact stored once, to keep writes fast and safe | Denormalized, such as a star schema, to make big reads fast |
How analytics evolved: warehouses and lakes
OLTP is still almost always handled by a relational database, because it's built for fast, safe transactions. The analytical side has changed much more:
- Reports on the live database. Early on, companies ran reports directly against their OLTP systems, and slowed them down for everyone.
- Data warehouses (1990s onward). A separate database, designed for analysis, holds cleaned and structured history from across the business.
- Data lakes (2010s onward). As companies collected huge amounts of logs, clickstreams, images, and sensor data that didn't fit neatly into tables, they started storing it all in cheap storage in its raw form, first on Hadoop clusters and now mostly in cloud object storage.
- Lakehouses (2020s). Newer platforms combine the two, adding warehouse-style tables and SQL on top of data lake storage.
| Data warehouse | Data lake | |
|---|---|---|
| What it stores | Structured, cleaned data in tables | Any data in its raw form: tables, JSON, logs, images, video |
| Schema | Schema on write: data is shaped before it's loaded | Schema on read: data is shaped when someone queries it |
| Main users | Business analysts and managers | Data scientists and data engineers |
| Typical use | Reports, dashboards, and business intelligence (BI) | Machine learning, exploration, and keeping everything for later |
| Storage cost | Higher per gigabyte | Low, using cloud object storage |
| Examples | Snowflake, Amazon Redshift, Google BigQuery, Azure Synapse Analytics | Amazon S3, Azure Data Lake Storage, Google Cloud Storage |
Popular data warehouse platforms
Most new data warehouses run in the cloud, where storage and computing power can grow as needed. A few long-standing platforms still run in companies' own data centers:
| Platform | Owner | License | Good to know |
|---|---|---|---|
| Snowflake | Snowflake Inc. | Commercial cloud service; storage and computing are billed separately. | Runs on AWS, Azure, and Google Cloud. Keeps storage and computing separate, so each can scale on its own. |
| Amazon Redshift | Amazon Web Services (AWS) | Commercial cloud service. | AWS's data warehouse, with a SQL dialect based on PostgreSQL. Redshift Spectrum can query files directly in Amazon S3. |
| Google BigQuery | Commercial cloud service; pay for the data each query scans, or reserve capacity. | Serverless: there are no servers to size or manage. Can query files in Google Cloud Storage without loading them first. | |
| Azure Synapse Analytics | Microsoft | Commercial cloud service. | Combines a SQL data warehouse with Apache Spark. Microsoft is steering new analytics projects toward Microsoft Fabric, launched in 2023, which includes its own warehouse. |
| Teradata | Teradata Corporation | Commercial (proprietary). | One of the original enterprise data warehouses, sold since the 1980s. Still common in large banks, retailers, and telecom companies, and now also offered in the cloud. |
The line between warehouses and lakes is blurring. Snowflake, BigQuery, and Redshift can all query files stored in a data lake, and lake platforms keep adding warehouse features.
Popular data lake platforms
Most data lakes today are built on cloud object storage, the same low-cost storage used for backups and files. Each major cloud has its own, and platforms such as Databricks add tools on top for processing and querying the data:
| Platform | Owner | License | Good to know |
|---|---|---|---|
| Amazon S3 | Amazon Web Services (AWS) | Commercial cloud service; you pay for what you store and read. | The most widely used storage for data lakes. AWS Lake Formation adds a catalog and access controls, and Amazon Athena queries the files with SQL. |
| Azure Data Lake Storage | Microsoft | Commercial cloud service. | Built on Azure Blob Storage, with real folders for organizing data. Used with Azure Synapse Analytics, Azure Databricks, and Microsoft Fabric. |
| Google Cloud Storage | Commercial cloud service. | Google Cloud's object storage. BigQuery can query lake files in place, and Dataproc runs Spark and Hadoop jobs on them. | |
| Databricks | Databricks, Inc., founded by the creators of Apache Spark | Commercial platform, built on open source projects such as Apache Spark and Delta Lake. | Runs on top of the storage of AWS, Azure, or Google Cloud. Popularized the lakehouse approach, combining lake storage with warehouse-style tables and SQL. |
| Apache Hadoop (HDFS) | The Apache Software Foundation | Open source and free, under the Apache License 2.0. | The original data lake technology, run on a company's own servers. Many companies have since moved their lakes to cloud storage. |
One company, both tools
An online retailer uses its data warehouse for the weekly sales report: revenue by region, top products, and returns, built from clean order data that ETL loads every night. The same retailer keeps every website click, search, and product image in its data lake, where data scientists use it to train the model that recommends products to each shopper.
Lakehouse platforms, such as Databricks and open table formats like Apache Iceberg and Delta Lake, aim to give you a warehouse's reliable tables and SQL on top of a lake's cheap, flexible storage.
Where the DBA fits
Analytics is often owned by data engineers and analysts, but DBAs play a key part in keeping it safe and reliable:
- Protect the source systems. Schedule and tune ETL jobs so pulling data out doesn't slow down the OLTP databases customers depend on. Running extracts against a replica, instead of the main database, is a common approach.
- Control access. Decide who can read which data in the warehouse and the lake, and apply the same security rules there as in production.
- Protect sensitive data. Make sure personal and financial data is masked or removed before it's copied into analytical systems, to stay compliant with laws such as GDPR and HIPAA.
- Manage retention and cost. Decide how long data is kept, and clean up what's no longer needed, since cloud warehouses and lakes are billed for every gigabyte stored and every query run.
Key takeaways
- A database is an organized collection of data. Querying it turns raw data into useful information.
- A DBMS is the software that manages databases. Data management moved from flat files to relational databases to NoSQL, each solving the previous approach's biggest problem.
- Oracle Database and SQL Server are commercial; PostgreSQL and MySQL are open source. All four are relational and use SQL.
- OLTP runs the business with many small, fast transactions. OLAP studies the business with large analytical queries, fed by ETL.
- Data warehouses hold structured, cleaned data for reporting; data lakes hold raw data of any kind for data science. Lakehouses combine the two.
- DBAs keep analytics safe: protecting source systems from ETL load, controlling access, masking sensitive data, and managing retention and cost.