Search code examples
nhibernatedata-modelingdatamodelsharp-architecture

Datamodel for temporary users for a forum


I have created a forum, but have now found out that to create more traffic I need to enable anonymous users to add posts.

The idea is that a user who doesn't have an account, can write a post, and fill out the following fields (as you can with stackoverflow):

[UserName][Email][Message]

The datamodel is looking something like this (A bit simplified):

ForumThread/ForumPost: [Id][CreatedDate][Title][Message][UserId]...

User: [Name][Email][CreatedDate][Address][City]...

The question is now, what is the best way to extend the existing datamodel to support anonymous users. Anonymous users don't need all the fields as the regular users e.g. Address etc. The pragmatic way would be to create a UserType describing the different types of users, or I could use some inheritance of a user, but this requires quite a bit of redoing.

Is there a third option I have forgotten?


Solution

  • Add a Role property to the User and have Anonymous and Registered as roles. Leave the properties null that are irrelevant to anonymous users. Although personally, I would just refactor into subtypes.