A-Z Popular Blog Databases Search »
Databases
 Advertisements
Related Guides

What is a Unique Constraint?

 , updated on
A unique constraint is a field or set of fields that must be unique for each row in a table. Data architects define unique constraints so that databases will automatically enforce the logical validity of data. Where a unique constraint is defined, the database will not permit duplicate values for the field or set of fields in the constraint definition.

Primary Key vs Unique Constraint

A primary key is a defined field or set of fields that a data architect identifies as the selected way to relate to a table. Once defined, all foreign keys that relate to the table must do so with the primary key. Only one primary key can be defined for a table.
A primary key automatically has a unique constraint applied to it. As only one primary key can be defined in a table, subsequent definitions to prevent duplicates in tables are defined with a unique constraint.

Example

A CUSTOMER table has an ID as a primary key and NAME, MOBILE_PHONE as a unique constraint. Foreign keys relate to the table using ID. It is impossible to enter someone with the same name and mobile phone number into the table as the database will throw an error.
Overview: Unique Constraint
Type
Definition
A field or set of fields that must be unique for each row in a table.
Value
Prevents data duplication.
Related Concepts
Next: Foreign Key
More about databases:
Atomicity
Database Index
Candidate Key
Databases
Data Purging
Dataset
Foreign Key
Federated Databases
Primary Key
Operational Database
Referential Integrity
Unique Constraint
If you enjoyed this page, please consider bookmarking Simplicable.
 

Databases

A list of database terms.

Referential Integrity

An overview of referential integrity with an example.

Primary Key vs Candidate Key

The difference between primary key and candidate key including an example.

Atomicity

The definition of atomicity with common examples.

Operational Database

A definition of operational database with examples.

Database Skills

A list of common database skills.

Row vs Column

The difference between row and column explained with examples.

Data

An overview of data with a list of examples.

Social Data

An overview of social data with examples.

Information Things

A list of things that can be considered information.

IT Gaps

An overview of IT gaps with examples.

Data Quality Examples

An overview of data quality with examples.

Legacy Data

An overview of legacy data with examples.

Customer Analytics

An overview of customer analytics with examples.

Uncertainty Principle

An overview of the uncertainty principle with examples.

Regression Analysis

An overview of regression analysis with examples.

Unstructured Data

A definition of unstructured data with examples.
The most popular articles on Simplicable in the past day.

New Articles

Recent posts or updates on Simplicable.
Site Map