Do underscores in table names affect performance or cause issues on some platforms?
For example, user_profiles
Would it be better to use user
There is no problem using underscores. I think it is just personal preference.
Nope, underscores in a database never cause any issues at all. My experience say that it is a better idea to identify any words in a database column.
If we use 'thisIsMyColumn' as a column name it's easy to write them, but 'this_is_my_column' as column name is more readable than the previous one.
There's nothing wrong with using underscores, but keep in mind there may be occassions you need to escape the underscore, e.g. My\_Table
No, it's perfectly good. In fact, it is the most recommended naming from MySQL (based on who they name their internal tables!).
Be aware that naming that in Microsoft Windows the default MySQL behaviour is to lower-case your table names. This may cause problems. I am not sure what causes this.
However I personally prefer to name my tables like UserLikesPage
, User
and PostComment
for example, since it reflects the class name in my code and I don't use Windows with MySQL.
You can simply add grave accent (`) before and after column name. For example:
CREATE TABLE USERS(
`PERSON_ID` NVARCHAR(100),
`FNAME` NVARCHAR(255),
`LNAME` NVARCHAR(255),
PRIMARY KEY (`PERSON_ID`)
);