From what I have read - and did not know before - a MySQL field with a Unique Key/Index can contain NULLs.

Starting a few months ago, when I create a new table, I like to make the first field be "ID", and set it as AutoIncrement, Null = No, Index = Unique. (That serves as a pseudo Primary Key.)

Then, when possible, I look for another field which has a "natural" key in it (e.g. article_slug, username, etc), and I make that my Primary Key. (If I can't find a "natural" key, then I would just make the "ID" the Primary Key.)

Any issues with that approach?

To me, even if a Unique Indexed field in MySQL can contain NULLs, that wouldn't be able to happen if you have the field set as AutoIncrement, Null = No. (Unless someone tinkered with things on the backend. And since only I have access to the database, that wouldn't apply.)

Sincerely,


Debbie