views:

36

answers:

1

I allow anonyous users to post a comment. I generate a GUID and insert them into a userTable and assign an anonymous role.

I dont save much other than the post itself tso the user table fields are pretty much empty.

My concern is that I will have unnecessary rows in the user table which I then have to go in at some point and erase and risk messing things up. And aslo that generating a GUID and doing the extra insertion is expensive?

What is the point to do what im doing vs simply storing the post with a GUID shared by all anonymous posts?

can someone assess efficacy here?

+2  A: 

I would store these unauthenticated users in a separate table, migrating them to your main user table when they authenticate or signup. This will allow you to easily purge them when they haven't visited in a couple of months.

I assume, to some extent, that you set a cookie or something that allows you to do some tracking, otherwise I don't see much point in creating a guid and going to all the work of creating a user at all.

Kaleb Pederson
what if my post table has userID as foreign key? would creating a single anonymous user be appropriate and reusing?
zsharp
It's reasonable if you aren't going to need a lot of code to handle the various cases. For example, if you display user statistics, you probably don't want that user showing up. Special cases are always troublesome, so consider what will be easiest in the long run and what you truly need to accomplish now.
Kaleb Pederson