unique constraint

A constraint that no two rows may have the same value in a column or combination of columns.

In more detail

If a write would create a duplicate, the database rejects it with an error instead of storing it. Unique constraints protect data such as email addresses or user names that must identify one record.

Examples

In IndexedDB, an index created with { unique: true } makes a duplicate write fail and aborts the transaction.
A unique constraint on eventId in the consumer’s table.
In this course: Testing it means inserting a first row and asserting that the database rejects an identical second one. In SQL it is declared with UNIQUE on a column or table.

Related terms

Taught in

References