๐ŸŽ 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

View
A virtual table defined by a SQL query that provides a simplified or restricted view of data from one or more tables.
Prepared Statement
A pre-compiled SQL template that uses parameters instead of literal values, preventing SQL injection and improving performance.
JOIN
An SQL operation that combines rows from two or more tables based on a related column between them.
ACID
A set of four properties (Atomicity, Consistency, Isolation, Durability) that guarantee reliable database transactions.
Redis
An open-source, in-memory data store used as a database, cache, message broker, and queue with sub-millisecond response times.
Database Proxy
A middleware server that sits between applications and databases, providing connection pooling, load balancing, and query routing.
View All Databases Terms โ†’