OSCON 2006:PostgreSQL中的TimeTravel表

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/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值