Arrays
◈ 2 cardsPostgres columns can hold lists — query them directly.
A column that holds a list
Postgres columns can be arrays. Each book carries a tags text[]. Work with them:
'x' = ANY(tags)— does the array containx?tags @> ARRAY['a','b']— does it contain all of these?array_length(tags, 1)— how many elements (1 = first dimension)unnest(tags)— expand the array into one row per element
SELECT title FROM books WHERE tags @> ARRAY['science'];
(Note: array_length of an empty array {} is NULL, not 0 — a classic gotcha.)