How to name table columns

Most of the best practices for tables are also true for columns:

  • Be consistent
  • Don't mix different languages like German and English
  • Use snake case for column naming

Use well-known column names

There are a few common column names which are repeatedly used in a lot of applications. Most of these column names are enforced by frameworks like Ruby on Rails or Spring Framework.

Column name Meanining DDL
id Default primary key LONG, PRIMARY KEY, AUTOINCREMENT, UNIQUE
uuid or guid Public primary key for usage in larger applications UUID, PRIMARY KEY, UNIQUE
status Describes the status of this entity/row enum
Suffix _at Determines a point in time DATETIME or TIMESTAMP
created_by Who has created this row? Foreign Key to a user or author table, NOT NULL
created_at When has this row been created DATETIME or TIMESTAMP, NOT NULL
updated_by Who has updated this row? Foreign Key to a user or author table, either NULL (SQL UPDATE enforces this column) or NOT NULL (SQL UPDATE and INSERT enforces this column)
updated_at When has this row been updated? DATETIME or TIMESTAMP, either NULL (SQL UPDATE enforces this column) or NOT NULL (SQL UPDATE and INSERT enforces this column)