Arrays
Use for small fixed lists; prefer junction tables otherwise
type[]variableRecommended
Tags, labels, small fixed-size lists. Avoid for relationships.
Range
up to 1 GB total
Performance
Supports GIN indexes for containment queries. No foreign key support.
Comparison
Arrays vs junction tables: arrays are simpler for small, denormalized lists (tags, labels). For relationships with their own attributes or referential integrity, use a junction table.
SQL Example
CREATE TABLE articles (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
tags text[] NOT NULL DEFAULT '{}'
);
CREATE INDEX ON articles USING gin (tags);