简体   繁体   中英

Best way to store database item's previous state

I have an asp.net application with c# code-behind. This application is a dispatch system which allows the user to create a 'ride' (stored in a microsoft sql db) which is modified through various processes as its status goes from waiting>enroute>completed etc.. I am trying to find the best way to 'save' the previous state of this 'ride' db row before it is modified, thus enabling the user to 'undo' their previous changes. What might be the best construct to accomplish this? I considered using view-state, but since there will be many many 'rides' there must be a better way..

I would do this inside the database by creating a "history" table. Upon an "undo", simply revert the data back to the history that was saved.

Is undo state something transient (they can only undo while they're doing the current ride), or is it permanent (they can leave the app, come back to a ride they created a year ago, and press undo)?

The former would be a good candidate for viewstate. The latter necessitates a history table as in @Induster's answer.

I doubt the amount of state will significantly affect server performance. Test it out and see!

也许慢慢改变尺寸的答案是http://en.wikipedia.org/wiki/Slowly_changing_dimension

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM