Databases for Developers

Lesson 2 of 10 · 24 min

x
20%

Relational Databases & SQL

Relational databases store data in tables with rows and columns. Every table has a primary key that uniquely identifies each row, and foreign keys that express relationships between tables. SQL is the language you use to create, read, update, and delete that data. The power of relational databases comes from JOINs — combining rows from multiple tables based on a shared key. A well-designed schema with normalized tables and proper foreign keys prevents duplicated data and maintains consistency. PostgreSQL, MySQL, and SQL Server all speak standard SQL with minor dialects.

Before
Multiple round trips
-- Two separate queries
SELECT * FROM orders WHERE user_id = 42;
SELECT * FROM users WHERE id = 42;
After
Single JOIN query
-- One query with a JOIN
SELECT o.id, o.total, u.name, u.email
FROM orders o
JOIN users u ON u.id = o.user_id
WHERE o.user_id = 42;

Key Takeaway

JOINs let you compose data from multiple tables in a single query — the relational model's core advantage over document stores.

PreviousNext Lesson