开发者

Support Staging on SQL

I am designing a database and I wish it could support more than one version in another words, if I have an object - info, it can have one value on one version and another value on another version. I want to be able to create a new version: that mean all the info that was relevant to the old version should be relevant to current version, but if there will be changes on the new version, there will be record o开发者_运维百科f the old one.

I was thinking about adding another column of version, for all tables that i want to add "versioning" to, but that double the content of the table on each version.


A time tested way to do this is to have an StartDt and EndDt columns. The active column is the one where EndDt is null. Example for a person that changes emails:

ID   StartDt     EndDt        Name      Email
1    2011-01-01  2011-02-01   Joe       joe@hotmail.com
2    2011-02-01  2011-03-01   Joe       joe@yahoo.com
3    2011-03-01  null         Joe       joe@gmail.com
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜