这种情况下的理想方法是什么? [英] What is the ideal way for this scenario?

查看:60
本文介绍了这种情况下的理想方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个涉及一些数据输入的小型Web应用程序.棘手的部分(至少对我来说)是将数据输入分为几个步骤.为了更加清楚,下面是其中涉及的一些步骤.

1.用户在一页上输入标题信息,然后单击保存"按钮.用户被移至下一页.
2.他在另一页上输入详细信息,然后单击保存"按钮.用户被移至下一页.
3.他在最后一页上输入了更多详细信息,然后单击保存"按钮.

我这样做是因为我认为一次保存所有数据可能会在应用程序上引起性能问题,尤其是在使用量很大的情况下.我的问题是,如果用户在步骤3中单击取消",则也应该从数据库中删除步骤1和2中的数据.我相信这将需要进行事务处理,但是通过阅读网上的一些文章,事务处理有时会需要锁定表,并且还可能导致性能问题.我对此一无所知,我真的很想在编码之前先考虑一下方法,而不是反复试验.

我的问题是,对于这种情况,理想的方法是什么?

感谢您的帮助.

I am working on a small Web application that involves some data entry. The tricky part(at least for me) is the data entry is divided into several steps. To make it clearer, the following are some of the steps involved.

1. User enters header information on one page and clicks on save button. User is moved to the next page.
2. He enters the details on another page and clicks on save button. User is moved to the next page.
3. He enters some more details on the last page and clicks on save button.

I made it that way because I think saving all the data at once might cause performance issues on the application especially when the usage is quite heavy. My problem is, if the user clicks on cancel at step 3, data from steps 1 and 2 should also be deleted from the database. I believe this will require a transaction but going through some of the articles on the net, transactions will sometimes require table locking and might also cause performance issues. Im stuck with this one and I really want to think for the approach before coding, instead of doing trial and error.

My question is, what is the ideal approach for this kind of scenario?

Appreciate your help.

推荐答案

由于这是一个Web应用程序,因此在用户填写最后一步之前,您不应该在数据库中输入任何数据:他经过第1步和第2步,然后决定不完成第3步,而是去冲浪Dilbert卡通片?还是回家?

突然,您的数据完整性反而被击倒了.

而是将您在第1步和第2步中获得的信息存储在Session中,并在用户完成第3步并验证所有数据后将其全部保存到DB中.

顺便说一句:不要试图使您的软件无法解决我认为一次保存所有数据可能会导致性能问题" –尝试使它适合用户,以及他在工作流程中必须要做的事情.
除非用户要从文件中粘贴数百条记录,否则对性能的影响将是微不足道的.
Since this is a web app, you shouldn''t enter any data to your database until the user fills in the final step: what if he goes through steps 1 and 2 and then decides not to complete step 3, but to go surf for Dilbert cartoons instead? Or go home?

Suddenly your data integrity is shot to hell anyway.

Instead, store your info from steps 1 and 2 in the Session, and save it all to the DB when the user has completed step 3 and all data is verified.

BTW: Do try not to make your software work around "I think saving all the data at once might cause performance issues" - try to make it work around the user, and what he is going to have to do as part of his workflow.
Unless the user is pasting hundreds of records from a file, any performance hit is going to be pretty trivial.


这篇关于这种情况下的理想方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆