Yes, this has been asked before here and here. I'm curious as to whether the approach I'm considering is architecturally sound.
Let me start off by trying to describe what I'd like to be able to do with my object model:
class Person {
ISet<Roles> Roles { get; set; }
}
class RoleDefinition {
string Name { get; set; }
}
class RoleAssignment {
RoleDefinition Definition { get; set; }
Person Person { get; set; }
}
class UserRole : RoleAssignment {
public virtual string Login { get; set; }
public virtual string Password { get; set; }
}
With the intent being to be able to work with roles in the following manner:
// Find all "users" with a matching login
from user in userRolesRepository.FindAll(u => u.Login.StartsWith("abc"))
select user.Person;
To do this, I'm considering the following data model
Person table (Id, Name)
RoleDefinition table (Id, Name)
RoleAssignment table (Id, DefId, PersonId)
UserRole table (RoleAssignmentId, Login, Password)
AdminRole table (RoleAssignmentId, ...)
I'll map UserRole and AdminRole as joined-sublass to RoleAssignment in NHibernate.
So, that's a 1:1 between Person and UserRole and AdminRole, a 1:1 between UserRole and RoleAssignment, and an n:1 between RoleAssignment and RoleDefinition.
My question is this: Is this really a good model?
Are there better ways to model this without losing the ability for each role to have strongly typed, queryable properties? How well will it scale, considering I will be adding even more roles to the system as we move along?