Skip to content

Instantly share code, notes, and snippets.

@andyg1
Last active September 11, 2023 15:53
Show Gist options
  • Save andyg1/a3ae69042571e7669f88bf0959c876bd to your computer and use it in GitHub Desktop.
Save andyg1/a3ae69042571e7669f88bf0959c876bd to your computer and use it in GitHub Desktop.
Sensible database naming conventions

Sensible database naming conventions

Taken from this article:

  • Primary keys are always named id whatever the data type is.
  • Timestamps are past tense, suffixed …_at
  • Date, Time, and Datetime are not timestamps, name them freely.
  • Booleans are always positive and start with is_…
  • Numeric columns should be plural, like guesses or failures
  • Lists as JSON columns are plural, and may end with 1…_list1
  • Complex JSON trees can be named freely, but may end with …_tree
  • Foreign columns always end with …_id, like author_id
  • Foreign columns using non-id foreign columns can be suffixed as …_as_id
  • Multiple text columns may end with …_body
  • Multiple text columns for binary-encoded data may end with …_data
  • Binary columns always end with …_blob or …_binary
  • Columns for encoded data always end with …_encoded
  • Columns for encrypted data always end with …_encrypted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment