I have the following inheritance. A doctor is a parent class. A doctor can be a paediatrician, a dentist or an orthopaedic. Each doctor type have different properties (different domain logic) but they all share the same Id, Name and they also all can have many appointments.
public abstract class Doctor
{
public long Id { get; set; }
public string Name { get; set; }
}
public class Paediatrician : Doctor
{
// add some other properties specific only to Paediatrician.
}
public class Orthopaedic : Doctor
{
// add some other properties specific only to Orthopaedic.
}
public class Dentist : Doctor
{
// add some other properties specific only to Dentist.
}
public class Appointment
{
public long Id { get; set; }
public DateTime DateOfAppointment { get; set; }
}
public class Country
{
public long Id { get; set; }
public string Name { get; set; }
}
There is a one to many relationship here (a doctor can have many appointments). Question here is where do I add the Appointment relationship? Inside each child class or on the parent class? I have to set this relationship to my ORM so adding this relationship into each child class would produce three different relationships into my db whereas if I add it to the parent class only one? The same stands for Country table. Where do I add Country relationship? Only on the parent class or child classes?
One of the systems requirement that might affect my selection is that I have is to show a list view with the name of the doctor and the appointment date. So there are two ways of doing this. Either by calling each child class and aggregate the results or by calling parent class directly and get the appointments if I add the Appointment relationship to the parent class. I am stuck and don't know what is the correct way of doing this fundamentally.