Skip to content

Instantly share code, notes, and snippets.

@twolfson
Last active November 13, 2022 07:53
Show Gist options
  • Save twolfson/dbf5dbb673cbac88836d to your computer and use it in GitHub Desktop.
Save twolfson/dbf5dbb673cbac88836d to your computer and use it in GitHub Desktop.
Database column naming conventions

We have been going over a lot of naming conventions for our database. I would like to start recording the ideas and why they work/don't.

Using timestamps for stateful boolean column

This applies to having an archived state of an item. We attempted to draw a line at when a column is an action (e.g. archive) rather than a property (e.g. is_red). This idea means that we convert these "action" states to timestamp fields over booleans (e.g. archived_at: timestamp).

Conclusion

In order to keep data consistent, we must introduce the timestamp from a single service. This means that we must introduce an alternative endpoint to performing this action (e.g. PUT /item/:id/archive). This is fine but can lead to complications with pedantic REST frameworks.

Naming boolean columns

There are a lot of options for column naming:

  • Present tense (e.g. active)
  • Past tense (e.g. archived)
  • Qualifiers (e.g. is_active, is_archived, has_color)

We are deciding that we are going to use past tense for our columns and anything that is derivative (e.g. is_red means that there is a color attribute set to red), cannot be updated via a POST/PUT.

Conclusion

Indeterminate yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment