'Requesting for nested list of objects using Spring boot
I have a problem with mapping database objects. First, let me explain the scenario. I have 4 entities such that. Student, Course, Speciality, and Form. The relation between them is explained in the below picture. (Note: I accidentally, draw the relation between Course and Form as ManyToMany. It should be OneToMany(Form-Course). Also the same thing between Student and Course. It is not OneToOne. It should be OneToMany(Many students at one Course))
Now, let's dive into the problem. I need to create a dashboard for a student where he/she can see the information about the internship. A student can take only one Course at a time(after several weeks they can take a new course). Let me give an example. "A student is taking the Course with id CS101. The CS101 course has Specialties such that Python, Java, and C# and requires a total of 50 forms. 20 of them must be Java, 15 of them must be Python, and 15 of them must be C#. After two weeks, the student started to study CS205, which has two specialties such that PHP and Javascript. And totally, he should fill out 20 forms to meet the requirements of CS205. 10 for PHP and 10 for Javascript. " Now, I need to keep track of the Student's actions. I couldn't figure out what the Response should look like. I need to follow the number of Forms in each Specialty a student has to fill out, and so far how many of them are done. I am developing a Spring boot API, for this problem. I have an endpoint such that "/student/id/dashboard" for the dashboard.
This is how my Speciality looks like
{
"id": 2,
"description": "Spec2",
"course": {
"id": 1,
"name": "Course1"
}
}
This is my course response
{
"id": 1,
"name": "Course1"
}
For now, the Dashboard response looks like the following.
{
"id": 1,
"oasisId": 20170602012,
"noProcedures": 5,
"noPatientLogs": 0,
"courseName": "Course3",
"total": 40
}
I need to know where should I add the total amount of forms that should be filled out for each specialty and for each Course also how can I follow the number of filled out forms. I need to display them in the dashboard. I am really confused at that point. Any suggestion? Maybe, you can send me a JSON format of the response or a database table, explanation, etc. The following picture shows the basic structure of the dashboard.

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

