哪种方法更好 - 更改每个表中的跟踪属性与一个跟踪器表中的跟踪属性
我正在尝试在两种方法之间做出决定,以跟踪记录是否已更改以及更改时间和更改者。我对获取已更改的实际数据不感兴趣,而只想获取数据已更改的事实。我使用的是 SQL Server 2008。
第一种方法是在每个表中包含以下 6 列:创建于、创建者、上次更新于、上次更新者、删除于和删除者。
第二种方法是使用单个表,我们将其称为“更改跟踪器”,它具有这 6 列,其他表将具有到“更改跟踪器”表的 FK。
哪个是更好的做法,为什么?
另外,如果我在 SQL Server 中启用更改跟踪,是否需要这些列?
I am trying to decide between 2 approaches to tracking whether a record has changed or not and when and by whom. I am not interested in obtaining the actual data that has changed but only the fact that the data has changed. I am using SQL Server 2008.
First approach is to have the following 6 columns in each tables: Created On, Created By, Last Updated On, Last Updated by, Deleted On and Deleted By.
Second approach is to have a single table, let us call it Change Tracker, which has those 6 columns and other tables would have a FK to the Change Tracker table.
which is a better practice and why?
Also, do I need to have these columns if I enable change tracking in SQL Server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为第二种方法没有任何优点,总是使用第一种方法。
顺便说一句,deleted_by 和deleted_on 是冗余字段。 created_xx 和updated_xx 字段就足够了
i see no advantages of second approach, always using first one.
btw, deleted_by and deleted_on are redundant fields. created_xx and updated_xx fields are enough