Skip to main content

What Is a Database?

If you've ever kept a list of contacts in a notes app, a JSON file, or a spreadsheet, you've already felt the pain points: duplicates, inconsistent formats, and "Where did that row go?"

A database is a system for storing and retrieving data so it stays organized, consistent, and easy to search as it grows.

Core Concepts

At a high level, a database helps you do four things reliably:

  • Create data
  • Read data
  • Update data
  • Delete data
flowchart TD
A[Your App Needs Data] --> B{How complex is it?}
B -->|Small + simple| C[File (JSON / text)]
B -->|Manual editing| D[Spreadsheet]
B -->|Querying + integrity + growth| E[(Database)]
E --> F[SQL queries]
E --> G[Constraints keep data consistent]

Database vs DBMS

People often say "database" when they mean two different things:

TermMeaningExample
DatabaseThe stored data (and its structure)app.db
DBMSThe software that manages the databaseSQLite, PostgreSQL, MySQL

Why Not Just Use Files or Spreadsheets?

OptionGreat forPain points as you grow
Text/JSON filesVery small datasets; config; single-purpose storageHard to query; easy to corrupt; integrity is "on you"
SpreadsheetsManual entry; quick summaries; sharing with non-devsNo strong constraints; merges are painful; automation gets messy
DatabasesApps that need reliable querying and consistencyRequires learning schema + SQL (worth it)

Code Examples

SQL results are always shaped like a table: columns and rows.

-- A "result set" is tabular: rows and columns.
-- We are not creating a real table yet; this is just a quick example.
SELECT
'Ada Lovelace' AS name,
'ada@example.com' AS email;
nameemail
Ada Lovelaceada@example.com

SQLite-Specific Nuances

SQLite Nuance

With SQLite, a database is typically a single file on disk.

  • Your application reads and writes that file through the SQLite library
  • Moving a SQLite database can be as simple as moving the .db file

Common Pitfalls / Best Practices

Pitfall

Confusing a database with a spreadsheet.

A spreadsheet is optimized for human editing; a database is optimized for consistency, automation, and reliable querying.

Best Practice

Use a database when you need at least one of these:

  • Reliable querying (filtering, sorting, combining data)
  • Consistency rules (like "email must be unique")
  • Multiple parts of an app reading/writing the same data

Quick Challenge

Write a query that returns one row with two columns:

  • tool set to database
  • benefit set to queryable
View Solution
-- Two columns, one row.
SELECT
'database' AS tool,
'queryable' AS benefit;
toolbenefit
databasequeryable