Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any reason to still use snake case for database tables and columns?

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.)?

like image 939
dallin Avatar asked Apr 29 '13 21:04

dallin


People also ask

Should database columns be capitalized?

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.

Should database tables be capitalized?

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.

Should SQL columns be capitalized?

MySQL - the columns are absolutely case insensitive.

How do you name columns in database?

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.


1 Answers

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.

like image 192
Bohemian Avatar answered Sep 27 '22 16:09

Bohemian