@sargonpiraev

Relational database

#database

A relational database stores data in tables made of rows and columns.

The core idea is that data has structure. Tables describe entities, columns describe attributes, and relationships between tables are usually expressed with primary keys and foreign keys.

Example

An application can store users and orders in separate tables:

usersorders
idid
emailuser_id
nametotal

The orders.user_id column points back to users.id.

What it is good for

Relational databases are strong when the application needs:

  • structured data,
  • constraints,
  • transactions,
  • joins,
  • ad hoc queries,
  • strong consistency.

Tradeoff

The schema gives safety and clarity, but it also means the data model must be designed and migrated carefully.

Postgres is a common relational database. See Postgres, ACID, and Postgres transactions.