开发者

Best practice to remove the data added by user in demo site?

开发者 https://www.devze.com 2023-04-10 06:22 出处:网络
This is the first time I need to make the demo site(thats done with some sample data in PHP with PostgresSql).Currently we are allowing the user to login and do the operation thats are availab开发者_C

This is the first time I need to make the demo site(thats done with some sample data in PHP with PostgresSql).Currently we are allowing the user to login and do the operation thats are availab开发者_C百科le in the website.Whats I want to do is, once the user complete the operation I need to remove the data created by user.

But whats the problem is If user insert the data in DB created in the demo domain then if I delete the domain datas there may be another user insert or delete the datas in another session.So I dont want to display other user operation(such as insert,delete) to others.It wont conflict.How can I do this.


There are a few ways you could do something like that.

  1. Use the SESSION. Don't know if this is viable, but if you can simply place all of the data into mock objects in the SESSION you'll be fine.
  2. This might actually be 1b. You can use cookies to do the same thing with SESSION, but it is admittedly more annoying.
  3. Generate mock tables — each time a new user signs on, create a series of unique tables for that user, prefixed with a UID for that user. Yes, it does create schema-creep, but it also means you have an easy way to see what space can be reclaimed.
  4. Have the data "tagged" in some way in the DB. This could mean that you add some extra data to the front of some of the user's data which marks it at temporary in the DB. The problem with this, though, is that your SERIAL columns cannot properly reset as your sequences will stay on their current position after you've erased their data.


Create a new database for each demo user. Populate each new database with the sample data from a "master" database, that is never altered by someone who is trying the demo. Then when the user has finished with the demo, drop the entire database.

You may be able to refine this so that you only need to create a few temporary tables for each user, it really depends on exactly what data is modified by the user when they are using the demo.

0

精彩评论

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

关注公众号