The best way to name tables

bharath picture bharath · Jun 23, 2010 · Viewed 7k times · Source

Is it better to use underscore whilst naming tables or is it better to use camelcase?

Example table_name or tableName which one is better? Is there a reason to be using either, what is it?

Answer

Jay picture Jay · Jun 23, 2010

Some database engines are case-insensitive, and indeed will convert names to all lower-case on some outputs. Because of this, I've taken to using underscores between words and using all lower case.

MySQL respects case as I recall so this isn't an immediate issue for you. But I got burned on this once when I had to port a database from one engine to another -- I think it was from MySQL to Oracle but I wouldn't swear to that -- and all our camelCase names suddenly became run-together names.

I'll also second Rob Boek on the most important thing being consistency. And while we're on the subject, can I make a tangential comment about being consistent in field names? I'm working with a system now where I found that the field "prodid" in one table is in fact the exact same contents as "style" in another, and another system that has "delivereddate" in one table and "datedelivered" in another.