Relational Database
In one line
A relational database stores data in tables (rows and columns) linked by relationships, and uses SQL to query it.
In simple words
A relational database organizes data into tables. Each table has columns (the fields) and rows (the records). Tables are linked by relationships — typically a column in one table references the primary key of another table.
For example, a users table might have columns id, name, email. An orders table might have id, user_id, total. The user_id column in orders is a foreign key pointing to users.id, creating a relationship between orders and users.
Relational databases enforce a strict schema — every row must conform to the defined columns and types. They excel at complex queries, joins across tables, and transactional integrity. Examples: PostgreSQL, MySQL, SQLite, SQL Server, Oracle.
Example
-- Two related tables
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users(id),
total NUMERIC(10,2)
);The user_id foreign key in orders creates a relationship — each order belongs to a user.
Common confusions
Confused with: NoSQL
The difference: Relational databases use tables and SQL with a strict schema; NoSQL databases use flexible documents or key-value pairs without a fixed schema.
Related terms
Related Resources
Related Lessons
- Relational Model
Learn how relational databases organize data into tables.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.