What Is a Relational Database? Connect Records with Tables and Keys
A relational database stores information in tables of rows and columns and represents links between tables with keys. You can keep related facts, such as customers and orders, in separate tables and combine them with an SQL join. This works well when records have a clear structure and the database must enforce shared rules, but not every workload fits naturally into tables.
What do rows and columns represent?
A table describes one kind of thing. A row in customers might represent one customer; columns hold attributes such as an ID or email. The schema defines table names, column types, defaults, and constraints. The word “relation” also has a mathematical meaning: a relation is not simply a visual link between two tables. SQL products can return unordered results with duplicates, so use ORDER BY whenever order matters.
How do keys connect tables?
A primary key identifies a row. A foreign key refers to a key in another table and can prevent references to missing records. For example, orders.customer_id can reference customers.id, allowing one customer to have many orders.
CREATE TABLE customers (
id bigint PRIMARY KEY,
email text NOT NULL UNIQUE
);
CREATE TABLE orders (
id bigint PRIMARY KEY,
customer_id bigint NOT NULL REFERENCES customers(id),
placed_at timestamptz NOT NULL
);
SELECT c.email, o.id, o.placed_at
FROM customers AS c JOIN orders AS o ON o.customer_id = c.id
WHERE c.id = 42 ORDER BY o.placed_at DESC;The join combines records through their key instead of copying customer details into every order. A foreign key preserves referential integrity, but some products do not automatically index the referencing column. PostgreSQL recommends considering such an index for lookups during deletes or key changes; indexes also consume space and add write work, so use real queries to guide them.
When does the relational model fit?
It can fit orders, customers, and products when relationships are stable and several requests must preserve the same rules. Keys and constraints can enforce uniqueness and references; transactions group related changes, such as an order and its line items, into one commit or rollback.
If records vary greatly in shape or the application usually reads and writes one nested document as a unit, compare a document model. This is not a simple ranking: document databases may offer validation and transactions, and relational products may support JSON. Decide from the queries, change boundaries, integrity rules, and operating skills you need.
When designing, define what each table represents and its key; distinguish harmful duplication from intentional denormalization; choose delete behavior; evaluate indexes with representative queries; and protect concurrent updates with constraints, transactions, locks, or retry rules.
Sources and scope
[PostgreSQL 19 Tutorial](https://www.postgresql.org/docs/current/tutorial.html)
[PostgreSQL Constraints](https://www.postgresql.org/docs/current/ddl-constraints.html)
Official PostgreSQL documentation checked 2026-11-22 provides the concrete syntax examples. Details vary across products. The example was not executed.