Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: Performance & internals
Stage 5: Specialization

Part 01 / Topic 2 of 10

Relational databases, SQL and PostgreSQL

A relational database stores data in tables. A table is rows and columns, like a strict spreadsheet. Here are three rows of the products table from shopdb, the store database you will load at the end of this part:

 product_id |     name      |  price  
------------+---------------+---------
          1 | Laptop Pro 14 | 1200.00
          2 | Laptop Air 13 |  950.00
          3 | Phone X       |  799.00
  • Each row is one record (one product).
  • Each column has a name and a fixed type (a price is always a number).
  • Every table has a primary key — a column whose value identifies exactly one row (product_id here).
  • Tables relate to each other through foreign keys: an orders row points at the customer who placed it by storing their customer_id. That is the "relational" part, and it is where this model beats flat files completely.

SQL (Structured Query Language) is the language you use to talk to a relational database: create tables, insert rows, ask questions. You describe what you want; the database figures out how to get it.

PostgreSQL (often just "Postgres") is the relational database this course uses: open source, free, extremely capable, and one of the most loved databases in the industry — it runs at banks, startups and everything in between. The software that manages databases is called an RDBMS (relational database management system); PostgreSQL, MySQL, SQLite and SQL Server are all RDBMSs.

Relational is not the only model. Document stores (like MongoDB) keep free-form JSON documents; key-value stores (like Redis) keep values under a single key. They trade away the strict schema and cross-table guarantees for flexibility in specific jobs. When data has structure and relationships — customers placing orders for products — relational is the default choice, which is why SQL has been the industry's shared language for fifty years.

Almost all SQL you learn here works on any RDBMS. Where something is Postgres-specific, the lesson says so.

🧪 Quick quiz — answer from memory, then check.

  1. In a table, what is a row and what is a column?
  2. What does a foreign key guarantee?
  3. Is SQL a database? Is PostgreSQL a language?
Show the answers
  1. A row is one record; a column is one named, typed field that every row has.
  2. Each value in it matches a row in the referenced table — you cannot point an order at a customer who doesn't exist. (Postgres does not auto-index the referencing column; you add that yourself when needed — Stage 4.)
  3. No and no — SQL is the language, PostgreSQL is the database system (RDBMS) that understands it.

Done here? The practice set for Part 1 — 6 exercises with solutions — is on the part page.

Search the guide