Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use Camel Case for JS and Snake Case for your DB?

I have been told to use snake case in my DB and never camelCase. JSON API says to use dashes between words for object keys. Javascript, everyone uses camelCase.

If I have a RAILS server getting data from an SQL database, sending it as json and being used in javascript, do I really need to convert between these notations?

Why not just use snake case everywhere?

like image 855
P0lska Avatar asked Oct 13 '15 04:10

P0lska


1 Answers

For JavaScript it is up to you (or the guidelines of the project) if you would like to use camel case or not. But because almost every majaor library and the core API uses camel cases it is a good idea to do the same, because then you wont need to think about if you need to use the one or the other.

For DBMS it depends on the operating system and DBMS because you might get technical problems when using mixed letters. E.g. if you have a MySQL database running on a Windows-System, then MySQL would not care about the case of the table names, because the file system is case insensitive. As of that the default MySQL configuration on Windows will automatically convert all table names to lowercases. As long as your DBMS will stay on the windows machine this won't be a problem, but as soon as you decide to switch to a Linux base server then you will get huge problems to migrate your data from the windows to the linux box.

To be not dependent on those problems, it is common to only use lowercase letters with DBMS, no matter if the DBMS would have problems with uppercase letters or not. With lowercase letters you will definitely have no problems and with uppercase letters you need to do investigations if it can be a problem.

like image 105
t.niese Avatar answered Sep 21 '22 23:09

t.niese