且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在数据库中维护历史

更新时间:2023-01-12 13:39:28

看看 http://www.simple-talk.com/sql/database-administration/database-design-a-point-in-time-architecture.

基本上,文章建议您在需要跟踪历史记录的表格中包含以下列 -

Basically, the article suggests that you have the following columns in the tables you need to track history for -

* DateCreated – the actual date on which the given row was inserted.
* DateEffective – the date on which the given row became effective.
* DateEnd – the date on which the given row ceased to be effective.
* DateReplaced – the date on which the given row was replaced by another row.
* OperatorCode – the unique identifier of the person (or system) that created the row. 

DateEffective 和 DateEnd 一起告诉您该行的有效时间(或员工在某个部门的时间,或他获得特定薪水的时间).

DateEffective and DateEnd together tell you the time for which the row was valid (or the time for which an employee was in a department, or the time for which he earned a particular salary).