...

/

History Tables and Audit Trails

History Tables and Audit Trails

Learn how to use history tables in PostgreSQL.

Use case: Maintaining previous versions or an archive

Some business cases require a full history of changes available for audit trails. What’s usually done is to maintain live data in the main table, modeled with the rules we already saw, and model a specific history table covering where to maintain previous versions of the rows or an archive.

History table and denormalization

A history table itself isn’t a denormalized version of the main table but rather another version of the model entirely, with a different primary key to begin with.

Access this course and 1400+ top-rated courses and projects.