Persistent storage.
WHAT KINDS EXIST
Relational, with structured tables and defined relationships Document, storing flexible structures Key-value, for simple fast lookup Others, for specific purposes
WHAT TO USE FOR MOST APPLICATIONS
Relational, unless there is a specific reason otherwise.
WHY
Structure, constraints and mature tooling, and most data is relational.
WHAT TO DEFINE
Tables, their columns and types Relationships, enforced by constraints Indexes on what you filter, sort and join by
WHY CONSTRAINTS
They enforce correctness even when code has a bug.
WHY INDEXES
Without them the database examines every row.
WHAT TO NEVER DO
Build queries by joining strings containing input.
WHAT TO DO INSTEAD
Parameterise, always.
WHAT TO USE FOR MONEY
Exact decimal types, never floating point.
WHAT TO MANAGE AS CODE
Schema changes, as versioned migrations committed with the application.
WHAT TO WATCH
Queries issued inside loops, producing one query per item.
WHAT THAT IS
The commonest performance fault in data-driven applications.