I am confused about creating a database and I need your help. I want to create a small-scale hospital management system. Here I want to create my users using Microsoft.Identity, but the point I am stuck at is that I will have more than one type of user. For example, doctors, patients, staff and visitors. Here, the users will have different properties and different tables that they will be connected to. How should I create my tables considering these? I have a few methods in mind, but I couldn’t decide which one is the best.
Scenario 1: Inheriting AppUser and creating Doctor, Patient, Staff and Visitor tables, as follows.
public class AppUser : IdentityUser<string>
{
public string NameSurname { get; set; }
public string? Gender { get; set; }
public string? IdentityNo { get; set; }
public string? GSM { get; set; }
public string? GSMPersonal { get; set; }
public int CountyId { get; set; }
public int CityId { get; set; }
public string? CityName { get; set; }
public string? Address { get; set; }
public int StatusId { get; set; }
public DateTime BirthDate { get; set; }
public string? MemberDetailsJSON { get; set; }
public string? RefreshToken { get; set; }
public DateTime? RefreshTokenEndDate { get; set; }
public virtual Doctor Doctor { get; set; }
public virtual Patient Patient { get; set; }
public virtual Staff Staff { get; set; }
public virtual Visitor Visitor { get; set; }
}
public class Doctor : AppUser
{
public string AppUserId { get; set; }
public int SpecializationId { get; set; }
public int DepartmentId { get; set; }
public string LicenseNumber { get; set; }
public DateTime DoctorStartDate { get; set; }
public DateTime? DoctorLeftDate { get; set; }
public virtual AppUser AppUser { get; set; }
}
public class Patient : AppUser
{
public string AppUserId { get; set; }
public virtual AppUser AppUser { get; set; }
}
public class Staff : AppUser
{
public string AppUserId { get; set; }
public int DepartmentId { get; set; }
public virtual Department? Department { get; set; }
public virtual AppUser AppUser { get; set; }
}
public class Visitor : AppUser
{
public string AppUserId { get; set; }
public Guid PatientGuid { get; set; }
public string VisitorCode { get; set; }
public DateTime VisitDate { get; set; }
public string? VisitDesc { get; set; }
public virtual AppUser AppUser { get; set; }
}
Scenario 2: Perform the necessary operations using subclasses using table-per-hierarchy.
At this point, I can’t decide what approach to take. Can you help me with this?