Is there any convention for database names in MySQL/MariaDB? I've searched Google and this Stack Exchange and haven't been able to find anything. Not even a "Nope, there's no official convention." Is there a standard, or is this something that's decided on a case-by-case basis?

Thank you.

  • 1
    Welcome to Database Administrators - you may want to take the tour to fully understand how StackExchange works. – Max Vernon May 25 '18 at 14:52
  • There are conventions for naming fields and tables - I like this (apart from the camelCaseNamingConvention) - I use under_scores_to_name_tables and lower_case for everything. SQL keywords in ALL-CAPs - makes queries/statements easy to read! – Vérace May 28 '18 at 9:05

Database names are completely up to the person creating them. Having said that, it makes sense to use some kind of sane naming convention.

Don't use reserved keywords, don't put spaces in the name, etc. Essentially, follow the MySQL Documentation for identifiers, and add a little common sense that applies to your environment.

|improve this answer|||||
  • 2
    Great, thank you. It's good to finally have a solid answer. – senox13 May 25 '18 at 16:29
  • 1
    This is especially true when you come back to something after not looking at it for many months. Good naming choices help understanding on what a table is for. Same goes for column names. – Dave May 25 '18 at 18:53

On beyond the database names...

Don't prefix table names with the database name.

Don't prefix column names with the table name. A possible exception is id --> foo_id to be consistent with references to it in other tables.

Why? Too much clutter. And, when JOINing, you should use table names (or aliases) on every column name to make it clear what table the column comes from.

The column name id should be INT (of some size), UNSIGNED, AUTO_INCREMENT, and (usually) the PRIMARY KEY.

Other column names should be 'meaningful' and not misleading.

|improve this answer|||||

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.