2018-05-10 16:04 GMT-03:00 Eugene Wang <eugenewangfw@gmail.com>: > Unique Constraint and Unique Index should be the same in this single-column > case, right?
The unique index is what enforces the uniqueness of the field with a UNIQUE constraint, but a unique index is not necessarily a constraint.
Specifically, a constraint cannot have a WHERE clause while the index can (i.e., unique indexes can be partial, unique constraints always cover the entire table).
Thinking this over I'd probably remove UNIQUE from both existing examples. I'd then add an example of a partial unique index (especially since we lack an example of a partial index presently) - and note that non-partial unique indexes are better implemented by defining a constraint on the relation as opposed to creating the index explicitly.