CHECK CONSTRAINT
CHECK (marks BETWEEN 0 AND 100) rejects out-of-range values. Enforced in MySQL 8.0.16+. Older versions accepted the syntax and ignored it — a famous trap.
Keep CHECKs simple. Heavy rules belong in the app + CHECK as a last line of defence.
Trap — promising CHECK on 5.7.
On the example next to this theory: CHECK CONSTRAINT — keys and constraints protect data integrity; indexes speed lookups.
Exam tip
CHECK (marks BETWEEN 0 AND 100) — MySQL 8.0.16+.