>_ IzzyLab

Topic breakdown

Constraints in PostgreSQL are declared right inside CREATE TABLE next to the column: PRIMARY KEY gives uniqueness plus a NULL ban and automatically creates a unique index, while NOT NULL merely forbids an empty value with no uniqueness requirement. Special attention to the choice of type for money: an exact decimal type (numeric/decimal) stores sums without rounding errors, whereas float/real is an approximate binary representation that makes fractions "drift." Mental model: column names and order come from the task, while each column's type is chosen to fit its meaning. It's convenient to view a table's structure with the \d command in psql.

What's checked

  1. products has a PRIMARY KEY
  2. column name declared NOT NULL
  3. id is an integer, price is numeric

What it looks like