I have a database with three entities that relate: user, process_selective and courses. The goal is to model the bank to meet the following requirements:
- User can subscribe to multiple selective processes
- Each selection process may or may not have related courses (depending on the type of process).
- When a selective process has courses, the user must select the courses that he wants to participate and also set a priority for each one, as it will be selected for only one.
Given that courses and priority are not mandatory fields - there are processes that do not have courses. Is the best way to do this would be by using ternary relations with the three foreign keys?
this way it would look like:
table_inscriptions
id_usuario (FK)(PK)(NN)
id_processo (FK)(PK)(NN)
id_curso (FK)(quando o processo não tiver curso, esse campo será NULL)
prioridade(quando o processo não tiver curso, esse campo será NULL)
If it is correct, what would the query look like to select all the processes a user is enrolled in along with the courses and the priority between them.
I'm a beginner and this problem seemed quite complex. Could someone help?