Tuesday, February 17, 2026

SQL: Postgres patterns

good patterns or anti-patterns for db design?

this is quote common now, and for sure is taking more space... 

but it is often useful to have more data;

trouble is that common relational mode does allow update and delete...

and there is no storage optimization.

Life Altering Postgresql Patterns

  • Use UUID primary keys
  • Give everything created_at and updated_at
  • on update restrict on delete restrict
  • Use schemas
  • Enum tables
  • Name your tables singularly
  • Mechanically name join tables
  • Almost always soft delete
  • Represent statuses as a log
  • Mark special rows with a system_id
  • Use views sparingly
  • JSON Queries

No comments: