Category Image MySQL table and column naming conventions.


MySQL has a list of reserved words , and while the documentation says you can use them if you surround them with backticks ( ` ), you should not use them because EOF will not put backticks on them for you. Besides, portability is important.


How do I handle it? Well, just like Apple uses NS, WO, etc. as a prefix in all its java class names, I recommend using a prefix in both your java class names and corresponding table names. For example if you have an address object and your company is named Widgets For Everyone, then you could for example use "WFAddress.java" for your java class and "wfaddress" for the table name. Doing this allows you to use even common words that are reserved such as user ... for example, "WFUser.java" and "wfuser"

Note that you should also avoid using function names as table/column names since these can also cause problems. As demonstrated by the fact that User is not listed as a reserved word, but there is a MySQL function called User , so if you name a table "user" you will get errors.

Note that for MySQL, I recommend using all lowercase for all table and column names (including the prefix used for name space conflict prevention). This will prevent locking you and your code into one platform. See the section, http://www.mysql.com/doc/en/Name_case_sensitivity.html , in the MySQL manual for more details.

Posted: Friday - January 30, 2004 at 10:43 AM        


Published by