
They even go so far as to say that PK data should be "meaningless": Sometimes, you may want use meaningful data, which considers being unique, for the primary keys e.g., social security number (SSN), vehicle identification number (VIN), email, and phone number. MySQL is far from unique on its handling of numeric data another page on Primary Keys in Oracle states that "primary keys typically are numeric because Oracle typically processes numbers faster than any other data types." And you should ensure sure that value ranges of the integer type for the primary key are sufficient for storing all possible rows that the table may have. Speaking about MySQL, states: Because MySQL works faster with integers, the data type of the primary key column should be the integer e.g., INT, BIGINT.

There are plenty of reputable reference sites who echo that sentiment. This opinion was reinforced by my first employer, the Federal Government, who utilized numeric PKs, even if that meant adding a surrogate key.

Say Aye for Numeric Typesīack when I was first learning about database development, I was instructed that numeric types are best for PKs because they are both faster and memory efficient. But that doesn't mean that one type may offer some advantages over the other. So long as your PK satisfies the above criteria, then you're good to go, as far as DB vendors are concerned.

For starters, the string data type is a generic IT term that traditionally refers a sequence of characters, either as a literal constant or as some kind of variable. String and Numeric Data Types in Relational Databasesīoth string and numeric nomenclatures are actually umbrella terms that encapsulate several different data types. Today's instalment will explore String and Numeric data types as Primary Keys in an effort to ascertain whether one is preferable to the other. In Part 1, we covered Natural and Surrogate Primary Keys and considered why one might choose one over the other.
Navicat for mysql key series#
Welcome back to this series on choosing a Primary Key for relational databases. Choosing a Primary Key - Part 2 by Robert Gravelle String vs.
