# DB02003: Constraint Violation

## What This Means[​](#what-this-means "Direct link to What This Means")

The data you're trying to save violates database rules. Constraints ensure data integrity by enforcing rules about what data can be stored.

## Common Causes[​](#common-causes "Direct link to Common Causes")

* **Missing required data** — A required field is empty
* **Invalid relationship** — Referencing a record that doesn't exist
* **Data type mismatch** — Wrong type of data for the field
* **Value out of range** — Number exceeds allowed limits

## How to Fix[​](#how-to-fix "Direct link to How to Fix")

### 1. Check Required Fields[​](#1-check-required-fields "Direct link to 1. Check Required Fields")

Ensure all required data is provided:

* Customer information (if required)
* Product details
* Order line items

### 2. Verify References[​](#2-verify-references "Direct link to 2. Verify References")

If the error involves relationships:

* Ensure referenced products exist
* Check that customer IDs are valid
* Verify category assignments

### 3. Review Data Values[​](#3-review-data-values "Direct link to 3. Review Data Values")

Check for invalid values:

* Negative quantities where not allowed
* Prices exceeding limits
* Invalid status values

### 4. Sync Latest Data[​](#4-sync-latest-data "Direct link to 4. Sync Latest Data")

The referenced data may be out of sync:

* Refresh data from server
* Wait for sync to complete
* Retry the operation

### 5. Clear and Retry[​](#5-clear-and-retry "Direct link to 5. Clear and Retry")

If data is corrupted:

1. Clear the problematic form
2. Re-enter the data
3. Submit again

## Common Constraint Examples[​](#common-constraint-examples "Direct link to Common Constraint Examples")

* **Quantity must be positive** — Can't add 0 or negative items
* **Price must be numeric** — Text not allowed in price fields
* **Customer must exist** — Can't assign order to non-existent customer

## Related Errors[​](#related-errors "Direct link to Related Errors")

* [DB02001](/error-codes/DB02001.md) — Duplicate Record
* [DB03003](/error-codes/DB03003.md) — Missing Required Field
