2

What is best practice for naming dbs, tables (collections) and fields among DBMSs?

I mean casing style, for example AaaBaa,aaa-bbb, aaa_bbb, AAA-BBB, aaaBbb, ...

I think if one exists it should be applicable to all DBMSs (MySQL, MongoDB, Oracle, ...), shouldn't it?

Currently I thing following is most appropriate:

Columns/Fields/Tables/Collections/Databases: aaaBbbCcc.

Could distinct case style for these object be useful at all?

  • In my opinion, there can be no objectively best practice with regard to object naming. Conventions, company policies, yes, a universally best choice, no. – Andriy M Nov 11 '12 at 12:31
  • There might be a general agreement on what to avoid using, though (like e.g. aAAAbBBB, perhaps). – Andriy M Nov 11 '12 at 12:35
1

It all boils down to personal preference and consistency within your team (or just yourself). Nothing worse than seeing different styles mixed.

As for SQL Server, be mindful of sp_yourProcName, as "sp_" prefix for a stored procedure can do funny things (read more about this from Aaron Bertrand).

Consistency is king. Make your choice and stick with it.

0

The SQL standard mandates that names are case-insensitive (specifically, that any lower-case letter in a name should compare equal to the corresponding upper-case letter).

For this reason, a table name with mixed case is a poor idea: the names ExpertsExchange is mandated to be equal to the name EXPERTSEXCHANGE. Letter case cannot distinguish those names in a conformant DBMS.

So, if you want to separate words in a name, don't use letter case. Instead, use the underscore (_) to separate words.

And, if you don't want your names to be shouty, spell them in all lower case.

For these reasons I recommend lower_case_with_underscore names.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.