Search code examples
mysqldatabaseisbn

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


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.


Solution

  • 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.