Unregistered users in the database

I am creating a discussion forum (of sorts) in ASP.NET MVC and I have a requirement to allow posts by unregistered visitors. Visitors need to provide a posting alias and optionally include an email address and website URL.

What is the best practice for handling messages by unregistered users in the database?

I'm a bit new to database design, but these options come to mind:

  • Insert a new record in the Users table for each post by an unregistered visitor. (Will simplify queries where records in the Posts and Users tables have a 1-to-1 relationship but inflate the Users table).
  • Create a new table for unregistered users and create new entries for new alias-email-url combinations, reuse existing ones. (In such a case, I have two foreign keys in the Posts table for RegisteredUserId and UnregisteredUserId?)
  • Add the unregistered fields "Alias", "UnregisteredEmail" and "Unregistered" directly to the "Records" table. (Horribly denormalized, but again this seems like a clean solution to me. Would I then make the UserId field of the Postsged table nullable and set it to null for those posts?).
  • An obvious solution that I haven't thought of yet?

Will any of these solutions create problems with LINQ To SQL mapping?

Edit:

To clarify, I need to store an alias (name) and an alternate email and URL for every post made by an unregistered visitor. This information is displayed with the message, so visitor! = Anonymous in this case.

+2


source to share


5 answers


I would go with the ASP.NET Membershipsystem box. You have the option to allow anonymous users. After the login is created, the account properties are migrated.



Unregistered users will need the "UserName" property. This will only be used to display the username. They will be identified by their anonymous user ID.

+2


source


Personally, I would choose option 1: "Insert a new record in the Users table for each post by an unregistered visitor."

Why? Well, User User, right? The fact that they have registered on your site becomes the property of that user (ie, the Field in your "Users" table).

Doing this way greatly simplifies your database design, allowing you to keep normal normalization and avoid having to introduce unnormalized duplication into the project (ie A having a table of "unregistered users" as well as "registered users" which I would consider as duplication and over-complicating design and relationships of your database objects).



Also, Option 1 makes your code a lot easier when an unregistered user wants to become a registered user. It becomes just setting a few fields in a custom record. Assuming your database relation will have a UserID field (as a foreign key) in your Messages table referring to the primary UserID key in your users table (or some such construct), you don't need to do anything when unregistered the user becomes a registered user, whereas with your other parameters, you will need to either delete (strike out) fields from potentially numerous previous posts (option 3), or delete and recreate records in multiple tables (option 2).

(assuming, of course, you don't want to keep the fact that the user was unregistered when some previous post was made!)

+1


source


The problem with a pseudonym is that without any form of user registration, another user will be able to post with the same pseudonym and thus "take over" their identity.

I think I'll either make the UserId optional in the Users table, or a 1-1 mapping between users and posts and add a second table to store Email / Url / (Alias) for unregistered users.

0


source


Have a user named "Unregistered" (or something like that) in your users table and have their own anonymous posts for that account.

In response to CraigRP's comment below:

I would either ask for a name in the text box and attach it to the bottom of the message like a signature. Or would not like to differentiate at all. Anonymous is anonymous, after all.

0


source


I think this is the same as your option3:

The message table will consist of

UserID (null) UnregisteredUserID (null)

and then the rest of the fields.

One of the UserIDs or Unregistered will be filled in.

If you don't have a "register new user" page, there is no point in adding a user to the users table.

0


source







All Articles