Module 00 · lesson 3

The relational model: tables, rows, columns

Remember the founder's messy notepad from the first lesson? Now GadgetHub's products live in a real products table, managed by PostgreSQL. Time to look inside it for the first time and give it its first command.

The relational model

Almost all modern databases are relational: the data sits in tables (also called relations). The table from lesson 1 is now real, in a database managed by PostgreSQL.

The products table schema

Every table has a schema — which columns it has and what's in them:

ColumnWhat it stores
idthe product's unique number
namethe name
categorythe category
priceprice, $
stockhow many are in stock
is_activewhether it's on sale right now
created_atwhen it was added

Your first command

To see all of a table's data, we tell the DBMS:

SELECT * FROM products;
  • SELECT — "show, pick";
  • * — "all columns";
  • FROM products — "from the products table".

Press Run — and the whole GadgetHub catalog appears on the right: 14 products, 7 columns. Congratulations — that's your first real SQL query! There's more to come.

Summary

  • The relational model = data in tables.
  • A schema is a table's columns and what they store.
  • SELECT * FROM <table> shows all of a table's data.