Ask A Question

Notifications

You’re not receiving notifications from this thread.

Naming conventions for database columns and variable names

Michael Victor asked in General

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?

Reply

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

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.