If you want to store an employee number, for which the maximum possible value is 500,000, the optimum datatype is MEDIUMINT UNSIGNED (which occupies 3 bytes). If you are storing it as INT, which occupies 4 bytes, you are wasting a byte for each row.
If you want to store the first name, for which the length is varying and the maximum possible value is 20, it is optimal to declare it as varchar(20). If you are storing it as char(20), and just a few names are 20 characters long while the remaining are less than 10 characters long, you are wasting space of 10 characters.
While declaring varchar columns, you should consider the length. Though varchar is optimized on-disk, while loading into memory, it occupies the full length. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.