What is a relational database?

A relational database stores data in tables of rows and columns and links those tables through shared keys, so information is recorded once and combined on demand.

Where does the relational model come from?

From a 1970 paper by Edgar F. Codd, who proposed describing data as mathematical relations, sets of tuples, and querying it with operations on those sets rather than by following pointers through files. The idea separated what data means from how it is stored, so programs no longer broke when storage changed. SQL grew out of that work and became the standard language. Half a century later, the model underpins most business software.

What are tables, rows and keys?

A table holds one kind of thing, such as customers or invoices; each row is one instance and each column one attribute with a declared type. A primary key uniquely identifies each row. A foreign key in one table refers to the primary key of another, recording a relationship: an invoice row carries the identifier of its customer. The database enforces those references, so an invoice cannot point at a customer who does not exist.

CREATE TABLE customer (
  customer_id  bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  email        text NOT NULL UNIQUE,
  country_code char(2) NOT NULL
);
CREATE TABLE invoice (
  invoice_id   bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  customer_id  bigint NOT NULL REFERENCES customer ON DELETE RESTRICT,
  issued_on    date NOT NULL DEFAULT current_date,
  total_cents  integer NOT NULL CHECK (total_cents >= 0)
);

Why do constraints matter?

Because they keep bad data out no matter which program writes it. NOT NULL, UNIQUE, CHECK and foreign key constraints are rules the database applies to every insert and update, from every application, script and manual fix. Validation only in application code eventually fails when a second program, a migration or a tired administrator writes directly to the tables. Constraints are cheap insurance and also document the data's meaning for the next developer.

What is normalisation?

Organising tables so each fact is stored once. If a customer's address is copied into every order, changing it means updating many rows and risking disagreement. Normalised designs move the address into the customer table and refer to it. The usual target is third normal form: every column depends on the key, the whole key and nothing but the key. Deliberate denormalisation, such as storing an order total, is fine when measured performance needs it and the copy is maintained carefully.

Design smellProblemNormalised fix
Customer address on every order rowUpdates must touch many rowsAddress in the customer table
Columns phone1, phone2, phone3Fixed limit, awkward queriesSeparate phone table, one row per number
Comma-separated tags in one columnCannot index or joinTag table plus a link table

How do joins bring data back together?

By matching keys at query time. A join combines rows from two tables where a condition holds, usually a foreign key equal to a primary key. The planner chooses among nested loops, hash joins and merge joins depending on table sizes and available indexes. Because combination happens at query time, the same tables answer questions nobody anticipated when the schema was designed, which is the model's lasting strength.

How do indexes speed things up?

By keeping a sorted structure, usually a B-tree, that leads straight to matching rows. Without an index, finding invoices for one customer means reading the whole table; with an index on customer_id, the database walks a few tree levels and reads only the matching rows. Index the columns used in frequent filters, joins and sorts, starting with every foreign key. Each index costs space and slows writes slightly, so add them based on real query plans rather than guesswork.

CREATE INDEX invoice_customer_issued ON invoice (customer_id, issued_on DESC);

Which relational databases are common?

PostgreSQL, MySQL, MariaDB and SQLite among open-source systems, alongside commercial ones. PostgreSQL is known for rich SQL and extensions, MySQL and MariaDB for the PHP web ecosystem, and SQLite for embedding inside applications. Commercial licences such as SQL Server are not sold here, while the open-source engines need no licence on our machines. Our MySQL or PostgreSQL article compares the two most popular server engines.

What does a relational database need from a server?

Memory for its cache, fast durable storage for its log, and cores for concurrent queries. BUSINESS-2 2024, with 64 GB DDR5 and two NVMe drives, suits a busy application database at $109.80 a month; ENTERPRISE-a3 2026 handles large, highly concurrent systems. Our Database server article covers sizing and DBMS explains the engine internals that make transactions safe.

Machines for relational databases

ModelProcessorCoresMemoryDrivesPortPer month
ESSENTIAL-3AMD Ryzen 9 5900X1232 GB2x 512 GB SSD NVMe1 Gbps unmetered$61.20
BUSINESS-2 2024AMD EPYC 4344P864 GB2x 960 GB SSD NVMe3 Gbps unmetered$109.80
BUSINESS-4 2026AMD EPYC 4585PX1664 GB2x 960 GB SSD NVMe3 Gbps unmetered$212.40
ENTERPRISE-a3 2026AMD EPYC TURIN 935532128 GB2x 1.92 TB SSD NVMe5 Gbps unmetered$481.80

Related pages

DBMS

What a database management system does beyond storing data: queries, transactions, concurrency, recovery, security, and the main families in use today.

Read more

Relational or non-relational

A practical comparison of SQL and non-relational databases by data shape, consistency, scaling, queries and operations, with patterns that combine both.

Read more

MySQL or PostgreSQL

Choosing between the two most popular open-source databases: SQL features, replication, extensions, operations and the hardware each wants on a dedicated server.

Read more

PostgreSQL servers

Run PostgreSQL on dedicated hardware: current versions from the project repository, memory settings, NVMe planner costs, replicas, pgBackRest and failover.

Read more

Questions and answers

What makes a database relational?

Data stored in tables of rows and columns, linked by keys, and queried with set operations such as joins, usually through SQL.

What is a foreign key?

A column that refers to the primary key of another table, recording a relationship that the database enforces so references always point to existing rows.

What is third normal form?

A design level where every non-key column depends only on the table key, so each fact is stored once and updates cannot create contradictions.

Which columns should be indexed?

Columns used often in filters, joins and sorting, starting with foreign keys. Confirm with query plans, since each index slows writes a little.

Is SQLite a relational database?

Yes. SQLite is a relational database engine embedded in applications, storing a whole database in a single file without a separate server process.