Arrays: a column that holds a list
Tagging a blog post with three tags usually means a junction table: a
post_tags table with one row per post-tag pairing. That's the right call
when tags need their own metadata or you're querying them heavily - but for a
short, simple list attached to a row, Postgres lets you skip the extra table
entirely with a genuine array column type, TEXT[].
To check whether a specific value is one of the elements in an array column,
use = ANY(column). It's not a text search on some comma-joined string -
tags really is a list, and ANY checks list membership directly.
You have an articles table with columns id, title, and tags (a
TEXT[]).
Your task: return the title of every article tagged 'sql'.
You'll practice:
- Reading an array column
- Checking array membership with
value = ANY(column)