Back when I started with database design, for some reason it was recommended that you always use snake case (my_table_name) for tables and columns. I think this was especially true in MySQL. The reasoning was there were instances where capitalization would be lost or enforced. Flash forward to today and I see a lot of people using Pascal Case ("MyTableName"), which I would prefer.
Is there any reason to still use snake case for table and column names? Are there any instances where capitalization could be lost or enforced (say if changing database engines, OS's, etc.)?
Only Use Lowercase Letters, Numbers, and Underscores table. column pattern. Queries are harder to write if you use capital letters in table or column names. If everything is lowercase, no one has to remember if the users table is Users or users.
Table names are stored in lowercase on disk and name comparisons are not case-sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases.
MySQL - the columns are absolutely case insensitive.
Database object names, particularly column names, should be a noun describing the field or object. Avoid using words that are just data types such as text or timestamp . The latter is particularly bad as it provides zero context. Underscores separate words.
SQL is case-insensitive. Many databases fold names to lowercase when creating tables, so capitalisation is lost.
The only portable way to preserve "words" within names is to use snake case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With