Z
Z
z_a_p_a_r_a2019-01-06 04:35:56
Entity Framework
z_a_p_a_r_a, 2019-01-06 04:35:56

How to build a database structure correctly?

There are the following models:

  • duty
public class Duty
    {
        public int DutyId { get; set; }

        public int dateId { get; set; }
        public Date DateOfDuty { get; set; }

        public int typeOfDutyId { get; set; }
        public TypeOfDuty typeOfDuty { get; set; }

        public List<DutyOfPerson> DutyPerson { get; set; }
    }

TypeOfDuty
public class TypeOfDuty
    {
        public int typeOfDutyId { get; set; }
        public string Name { get; set; }
        public List<RoleInDuty> rolesInDuty { get; set; }
    }

RoleInDuty
public class RoleInDuty
    {
        public int roleInDutyId { get; set; }
        public string Name { get; set; }
        public int typeOfDutyId { get; set; }
    }

person
public class Person
    {
        public int PersonId { get; set; }
        public string Name { get; set; }
    
        public List<DutyOfPerson> DutyPerson{ get; set; }
    }

I create a connected class Person-Duty:
public class DutyPerson
    {
        public int DutyId { get; set; }
        public Duty Duty { get; set; }
        public int PersonId { get; set; }
        public Person Person { get; set; }
    }

Now it is possible to set the watch, its type and assign people to the watch, but how now to assign a role to a person in this watch?
Approximate database scheme 5c315a7d6a9ac810726328.png
And also to establish in what duty a person can participate and what roles he can perform (this is secondary). The first is clear how to execute => create a linked table of type PersonTypeOfDuty, but again, how to set what roles it can perform in these duties?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question