I was working with a customer today, and I noticed they used varchar(10) to store an ISBN. This got me thinking, is that the most efficient way of storing an ISBN?
Some quick googling revealed that it is always 10 characters in length, so while a varchar would take 11 bytes to store this, a char will only take 10 bytes (the extra byte in the varchar is required to maintain the length). But an ISBN is not a string, it's a number. To store a 10 digit number, I need a BIGINT(10) ZEROFILL; that brings it down to 8 bytes.
A bit more googling, and I find out that the tenth digit in the ISBN is actually a checksum. I think to myself for a second that if I can recreate that checksum, I can move down to an INT(9) ZEROFILL, which means 4 bytes. 4 bytes for storing what was previously 11 bytes!
Of course, I had to share my excitement with one of my colleagues, who then told me that as of Jan 07, ISBNs are moving to a 13 digit representation. Damn it, I'll have to stick to my BIGINT(13) ZEROFILL.
For those that are curious, 978 will prefix existing ISBNs