🗄️ Database Design / Normalization
Beginner
What is a CHECK constraint?
Answer
A CHECK constraint limits the values that can be stored in a column by specifying a condition that must evaluate to TRUE or NULL for each row. Examples: age INT CHECK (age >= 0 AND age <= 150), salary DECIMAL CHECK (salary > 0), status VARCHAR CHECK (status IN ('active', 'inactive', 'pending')). CHECK constraints enforce domain integrity at the database level, guaranteeing that invalid values can never enter the database regardless of which application writes to it. Violations raise a constraint error. Available in all major RDBMS (MySQL 8.0+, PostgreSQL, SQL Server, Oracle).
Previous
What is the difference between SQL and NoSQL databases?
Next
What are database anomalies and how does normalization prevent them?