Last post Jun 30, 2010 07:53 PM by marcinsw
Jun 30, 2010 02:34 PM|sjvworthog|LINK
I came across a design question that I did not have a good grasp on what the best practices or the best design would be. We have multiple roles in our application that need to login to our site. The problem is that each role has a different user profile
as in regards to what information we collect from them (i.e. one role has a business name attribute and the other roles do not). However we would like to keep one login page for all roles and keep the constraints of unique usernames across all roles.
Any opinions on how one would tackle this problem? The following is a list of what db scenarios I have thought of and I would load business object which inherits from a base user class using on one of these:
Jun 30, 2010 07:53 PM|marcinsw|LINK
Original ProfileProvider stores user's profiles as binary data (in sql it's called "image" type), so it's not a problem to store many different profiles in one table, if you use it. Problem is that it's designed to store only one profile per user, not role.
If you accept that fact, then your problem gets easier to solve. If user role is 1 then you unpack (deserialize) the binary data as class1, and if role is 2 then you threat it as profileclass2 - in other words you unpack the profile based on user's role. All
this is done on the server side not in DB.
If your users can have more than one role, and you want to keep many profiles for each user based on those roles, it gets more complicated. I would for sure stick to one user table, one role table and I would still store profiles as serialized binary data.
The only change would be to extend role table with one column: ProfileTypeId, that would specify what kind of profile each role uses. I would also create a table for ProfileTypes ProfileTypes with two columns: ProfileTypeId and TypeName.
But still storing profiles as binary would be my pick.
If you want to store profile values as columns in table, then option 2 seems to be the best for me. Just skip some fields when selecting, if user is not allowed to view it.