8

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.

0

2 Answers 2

7

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.

0
5

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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