A. Elein Mustain is a veteran developer of Ingres, Illustra, and Informix, and is the author of the weekly PostgreSQL General Bits column.
答:Elein Mustain是Ingres,Illustrator和Informix的资深开发人员,并且是每周PostgreSQL General Bits专栏的作者。
Elein showed how to use timestamps to keep an audit trail of all changes in your DB. With this technique, you never actually delete records, you just give them an end date. Multiple copies of a record (again, with timestamps for each one) also allow you to track edits. (This is a pretty standard approach, especially in ‘validated’ environments, or in government-regulated industries.)
Elein展示了如何使用时间戳来跟踪数据库中所有更改的跟踪。 使用这种技术,您实际上不会删除记录,而只是给它们指定一个结束日期。 记录的多个副本(同样,每个副本都有时间戳)也使您可以跟踪编辑。 (这是一种非常标准的方法,尤其是在“经过验证”的环境中或在政府监管的行业中。)
The value of using Postgres here is in the advanced features like triggers that you can use with your deletes and updates to offload the work needed to maintain this ‘time travel’ system — rather than forcing your app logic to keep up with all of it.
在此处使用Postgres的价值在于高级功能,例如触发器,您可以将其与删除和更新配合使用,以减轻维护此“时空旅行”系统所需的工作-而不是强迫您的应用程序逻辑与时俱进。
You can also use PostgreSQL’s views to query the database for only the current data, or write procedural functions to query the state of the database at a particular point in time in the past.
您也可以使用PostgreSQL视图来查询数据库中的当前数据,或者编写过程函数来查询过去特定时间点的数据库状态。
Elein has her slides available online here.
Elein的幻灯片在此处在线提供 。
翻译自: https://www.sitepoint.com/oscon-2006-timetravel-tables-in-postgresql/
相关资源:设计模式:Los 23 patrones dediseñoscon ejemplos-源码