What is the best data type for ISBN10 and ISBN13 in a MySQL datase

kipzes picture kipzes · Jun 23, 2016 · Viewed 9.7k times · Source

For an application I'm currently building I need a database to store books. The schema of the books table should contain the following attributes:

id, isbn10, isbn13, title, summary

What data types should I use for ISBN10 and ISBN13? My first thoughts where a biginteger but I've read some unsubstantiated comments that say I should use a varchar.

Answer

ceejayoz picture ceejayoz · Jun 23, 2016

You'll want a CHAR/VARCHAR (CHAR is probably the best choice, as you know the length - 10 and 13 characters). Numeric types like INTEGER will remove leading zeroes in ISBNs like 0-684-84328-5.