Strings as Primary Keys in MYSQL Database [closed]

Technically yes, but if a string makes sense to be the primary key then you should probably use it. This all depends on the size of the table you’re making it for and the length of the string that is going to be the primary key (longer strings == harder to compare). I wouldn’t necessarily use a string for a table that has millions of rows, but the amount of performance slowdown you’ll get by using a string on smaller tables will be minuscule to the headaches that you can have by having an integer that doesn’t mean anything in relation to the data.

Leave a Comment