๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Databases Beginner

What is Database Constraint?

Rules enforced by the database to maintain data integrity, including NOT NULL, UNIQUE, CHECK, PRIMARY KEY, and FOREIGN KEY.

Constraints are declarative rules that the database enforces automatically. NOT NULL prevents missing values. UNIQUE ensures no duplicate values in a column. CHECK validates that values meet a condition (e.g., price > 0). PRIMARY KEY combines NOT NULL and UNIQUE to identify rows. FOREIGN KEY enforces referential integrity between tables. EXCLUDE constraints (PostgreSQL) prevent overlapping ranges. Constraints catch data errors at the database level regardless of which application inserts data, providing a critical safety net that application-level validation alone cannot guarantee.

Related Terms

Database Backup
The process of creating copies of database data to protect against data loss from failures, corruption, or human error.
Row-Level Security (RLS)
A database feature that restricts which rows a user can access in a table based on security policies.
Deadlock
A situation where two or more transactions permanently block each other by each holding locks that the other needs.
Database Sharding
A horizontal scaling strategy that distributes data across multiple database servers based on a partition key.
Full-Text Search
A technique for searching natural language text in databases using word stemming, ranking, and relevance scoring.
Partitioning
A technique of dividing large database tables into smaller, more manageable segments while maintaining a single logical table.
View All Databases Terms โ†’