Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Naming conventions for database columns and variable names

General • Asked by Michael Victor

Is there a guide or best case practise to help people on choosing the best database column names (or even for variables?). I am not really looking at syntactical naming conventions such as snake case, camel case or even singular or plural.

Here is an example from what we faced. We have a column that would indicate that a user would want to become an admin when signing up and based on this triggers would be initiated. Some of the names that we came up with were wants_to_be_admin, intends_to_be_admin, wants_to_administer, potential_admin. These column names seem equivalent, but we would like to standardise the way we come up with these names.

How would you propose to start making this guide/convention in a company? Has this been done before?

would a convention for booleans like this work
Booleans for pending behaviour:
noun followed by past_tense_verb: admin_requested, account_requested, terms_requested, etc.

Booleans for current state:
present_tense_verb followed by noun: is_admin, has_account, accepted_terms, etc.,

In the past we have added a naming convention for tables and columns in our data dictionary. If you don't have documentation that is that formal, I would just add a page on a wiki or confluence

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,575+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.