Style for DB Field Names

Can you use camelCase for field names?

Or is it better (and safer) to use underscores between words?


metaDescription

meta_description

Debbie

if you want to, yes – but a lot depends on the platform you’re on

see MySQL :: MySQL 5.0 Reference Manual :: 8.2.2 Identifier Case Sensitivity

safer?

all naming conventions are safe to use

As long as you are consistent then you should be okay, right?

safer?

all naming conventions are safe to use

Safe, as in less prone to human/developer errors.

I use camelCase for my PHP variables, so I’m debating between being symmetric between PHP and MySQL, or using underscores in MySQL since I believe that is a more standard database convention.

Debbie

If you are on UNIX/LINUX/OSX no problem using CamelCase. If you are using Windows I think you have trouble because windows is case insensitive by default. I think there is a setting you can change in the my.ini file but don’t remember what it is.

Without making the change Database DATABASE and datABaSe are all the same name to Windows. Three separate names to *IX

Well, my web host is Linux, although I use my Mac for development and I just found out that OS X is case insensitive?! :eek:

I guess I’ll just be careful to not have camelCase and CAMELCASE and camelcase.

Debbie

Seems like you can install OSX filesystem as case sensitive or insensitive.
I don’t use it very often.

[ot]For those people finding this thread looking how to make MySQL case sensitive under windows.

You need to put lower_case_table_names=2 in my.ini, under the [mysqld] heading, or under [wampmysqld] if you’re using WAMP.
[/ot]