我正在设计这个数据库,必须保留员工薪资和组织内部动向的历史记录.基本上,我的设计有3个表(我的意思是,有更多的表,但对于这个问题我会提到3,所以请耐心等待).员工表(包含最新的薪水,职位数据等),SalaryHistory表(薪水,日期,原因等)和MovementHistory(Title,Dept.,comments).我将使用
Linq到sql,所以我想的是每次更新员工数据时,旧值将被复制到各自的历史表中.这是一个好方法吗?我应该使用Linq to sql或触发器吗?感谢您的任何帮助,建议或想法.
解决方法
看看
http://www.simple-talk.com/sql/database-administration/database-design-a-point-in-time-architecture.
基本上,本文建议您在跟踪历史记录的表格中包含以下列:
* 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一起告诉您行有效的时间(或员工在某个部门的时间,或者他获得特定薪水的时间).