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
- index — A separate, sorted structure a database keeps alongside a table so it can find matching rows without reading them all.
- transaction — A group of database changes that succeed or fail together, so the data is never left half-updated.
- idempotency — The property of an operation that gives the same result whether you run it once or many times, because a repeat run finds nothing left to do.
- deduplication — Detecting and discarding repeated copies of the same message or request, usually by remembering identifiers already processed.
- race condition — A bug whose outcome depends on the timing of two things happening at once.
- primary key — The column, or columns, whose value uniquely identifies each row of a table and can never be NULL.
- constraint — A rule the database enforces on stored data, such as a column that must be unique or not null.
- idempotency key — A unique value a client sends with a non-idempotent request, such as a create, so the server can recognise a retry and return the original result instead of acting twice.
- check then act — Reading whether something exists and then acting on the answer as two separate steps, which races under concurrency.
- database engine — The database software itself, such as PostgreSQL, MySQL or SQLite, which decides the features, SQL dialect and extensions available.
Taught in
- IndexedDB In Practice: Object Stores, Indexes And Transactions — Frontend Architecture & Web Platform
- Asynchronous Event Processing: Outbox Pattern & Queues — Production Full-Stack Engineering
- Keys, Constraints And Referential Integrity — PostgreSQL, Indexing & Relational Data Modeling
- Idempotency, And Exactly Once As A Fiction — Scalable System Design & Distributed Architecture
- Testing With Real Databases — Automated Testing, TDD & Quality Engineering