Insert multiple ids into a table

0

Hello,

I have the following problem:

I have the PERSON table and COURSE table, each person can choose more than one course, the id of the chosen courses need to be saved within the person table, what would be the best way to do it?

    
asked by anonymous 08.06.2016 / 02:49

1 answer

2

Ideally you'd have a table template look like this:

Inthesecasesyouaskyourself:

  • APersoncanhaveasmanyCourses?
  • TheAnsweris"N" Courses, a person can have from 0 to N courses.
  • A Course can have as many People ?
  • The answer is also "N", a course can range from 0 to N persons.

When we encounter this situation of NN there is a need to create an auxiliary table to connect the two tables that in the case is the table "Person_Course", it exists only for the purpose of making the connection of Person with Course.

    
08.06.2016 / 03:00