My app is supposed to have Medics and Participants.
我的应用应该有医生和参与者。
They are all supposed to be able to login to the Site.
他们都应该能够登录到网站。
So, right now what I have is this.
现在我得到的是这个。
public class Participant:Person
{
public string EmergencyContactNumber;
}
public class Medic:Person
{
public string MedicHospitalId;
}
public abstract class Person
{
public string FirstName;
public string LastName;
public string UserName; //this is the Membership Provider UserName to associate the MembershipUser to the Person thats logging into to the system.
}
The problem with this is that a Medic could eventually also be a Participant... and I dont want to have to create a new User for that.. How could I change my model to allow this feature?
这样做的问题是,医生最终也可能成为参与者……我不想为它创建一个新的用户。我如何改变我的模型来允许这个特性呢?
2 个解决方案
#1
1
i'd redo it to be a 'has a' instead of an 'is a' relationship. so instead of a medic being a person, it would be related to a person, like :
我把它改写成“有”而不是“是”的关系。所以医生不是一个人,而是一个人,比如:
public class Medic
{
public string MedicHospitalId;
public Person Person;
}
there would then be a medic table with a fk relationship with the person table. same thing for the participant. this would allow for a person to be both, and clean up the model a little i think.
然后将有一个与person表具有fk关系的medic表。参与者也是如此。这可以让一个人同时做到这一点,并且我认为可以把模型清理一下。
if you wanted to get even more crazy with it, you could denormalize it into more of an eav table, but that's for another day.
如果你想要更疯狂地使用它,你可以将它反规范化成更像eav的表格,但那是另一天的事了。
#2
0
Maybe roles will be good solution for you?
也许角色对你来说是一个很好的解决方案?
#1
1
i'd redo it to be a 'has a' instead of an 'is a' relationship. so instead of a medic being a person, it would be related to a person, like :
我把它改写成“有”而不是“是”的关系。所以医生不是一个人,而是一个人,比如:
public class Medic
{
public string MedicHospitalId;
public Person Person;
}
there would then be a medic table with a fk relationship with the person table. same thing for the participant. this would allow for a person to be both, and clean up the model a little i think.
然后将有一个与person表具有fk关系的medic表。参与者也是如此。这可以让一个人同时做到这一点,并且我认为可以把模型清理一下。
if you wanted to get even more crazy with it, you could denormalize it into more of an eav table, but that's for another day.
如果你想要更疯狂地使用它,你可以将它反规范化成更像eav的表格,但那是另一天的事了。
#2
0
Maybe roles will be good solution for you?
也许角色对你来说是一个很好的解决方案?