Composite UNIQUE checks the whole key tuple.

highlighted = computed this step

Composite key

A two-column UNIQUE rule checks the whole key tuple.

two-column key\text{two-column key}

Read tuple keys

The rule uses 2 key columns and finds 1 composite violation.

key columns=2\text{key columns}=2

UNIQUE constraint examples are tiny finite table checks; SQL dialect completeness, index implementation, locking, optimizer behavior, product behavior, and performance claims are out of scope.

Two-column UNIQUE: base rowsidemailregionplan1adaeastbasic2beneastpro3adawestbasic4NULLeasttrial5NULLwesttrial6cyeastbasic UNIQUE rulenamecolumnsuq_region_plan(region, plan) UNIQUE keys by source rowsourceinputkeykeyStatus0(1, ada, east, basic)(east, basic)checkable1(2, ben, east, pro)(east, pro)checkable2(3, ada, west, basic)(west, basic)checkable3(4, NULL, east, trial)(east, trial)checkable4(5, NULL, west, trial)(west, trial)checkable5(6, cy, east, basic)(east, basic)checkable UNIQUE violationsleftrightkeyreason05(east, basic)duplicate_non_NULL_key Insert candidate checkfieldvaluepresentno UNIQUE factsfactvaluerowCount6constraintNameuq_region_plankeyColumnCount2violationCount1tableValidnonullsCollideno_toy_SQL_like_conventioncandidateDecisionnone

Both values must match

Rows collide only when every non-NULL component in the tuple matches.

whole tuple matches\text{whole tuple matches}

Summary

Composite UNIQUE compares tuples, not columns one by one in isolation.

tuple rule\text{tuple rule}