Lesson 4 / 28

Data Types

Choosing the right column type for numbers, text and dates.

Numbers & text

Common types: INT for whole numbers, DECIMAL(p,s) for exact money values, VARCHAR(n) for variable-length text, TEXT for long text.

Dates & booleans

DATE, DATETIME and TIMESTAMP store date/time; BOOLEAN is really TINYINT(1) under the hood in MySQL.

DECIMAL vs FLOAT for money

Use DECIMAL for prices and money — FLOAT/DOUBLE can introduce rounding errors that matter when totals must be exact.