I have a question in the field of optimization and application design.
I am building a web application using asp.net and sql server.
In one of my screens I must perform an action that generates a random number of user ids. I present the viewer with some statistics about the selected users. If the viewer likes the statistics I want to save them.
So basically I need to save the temporary random data, and if user likes it keep it.
Should I store the generated ids in the database or should I store them in the session?
Well, since you are generating random ids, you are using some kind of pseudorandom generator. Have you considered the possibility of just storing the seed for that generator? I’ve recently had a similar issue. In fact, very similar. Have a look:
My Post about Random(int seed)
EDIT: In comments you suggest you want to do much of this on the SQL server. Have a look at the following post. In addition you may want to consider the special case of new user being added whilst your admin or whatever ponders if he “likes” to save this or not. In that case you’d need to additionally store the number of users when the request was made, and adjust your random selection function accordingly. In the even more special case of removed user, this approach, admittedly, is useless.
Seeding SQL