Ravindra BagaleCourses & study guides मराठी Track your progress

Ravi Sir's Cyber Security Cards › Revision Cards

Constraints: NOT NULL, DEFAULT, CHECK, AUTO_INCREMENT

Constraints: NOT NULL, DEFAULT, CHECK, AUTO_INCREMENT Constraints are rules the database enforces. NOT NULL : must have a value. DEFAULT : value if none given. CHECK : value must pass a test. AUTO_INCREMENT : number goes up by 1 each row. Even if app checks fail, CHECK (amount > 0) stops negative pa

Constraints: NOT NULL, DEFAULT, CHECK, AUTO_INCREMENT Constraints are rules the database enforces. NOT NULL : must have a value. DEFAULT : value if none given. CHECK : value must pass a test. AUTO_INCREMENT : number goes up by 1 each row. Even if app checks fail, CHECK (amount > 0) stops negative pa
Constraints: NOT NULL, DEFAULT, CHECK, AUTO_INCREMENT · Download PNG
Read card text

What this card says

What it is

Constraints are rules the database enforces.

NOT NULL: must have a value. DEFAULT: value if none given. CHECK: value must pass a test. AUTO_INCREMENT: number goes up by 1 each row.

Why it matters for security

Even if app checks fail, CHECK (amount > 0) stops negative payments.

Watch out

AUTO_INCREMENT IDs are easy to guess. If /invoice.php?id=1001 has no owner check, trying 1002 shows someone else’s invoice. That is IDOR.

ConstraintPurpose
NOT NULLValue is required
DEFAULTValue used when none is given
CHECKValue must satisfy a condition (enforced in MySQL 8.0.16+…
AUTO_INCREMENTAutomatic increasing number, usually for the primary key
UNIQUE, PRIMARY KEY, FOREIGN KEYCovered in section 11.5

Learn more in the lesson: 11.6 Constraints: NOT NULL, DEFAULT, CHECK, AUTO_INCREMENT

See all Ravi Sir's Cyber Security Cards