If there are List,Map or other classes as members in the Java PO class, how to design the corresponding fields of mysql?

the Java PO class has List,Map or other classes as members, and mybatis acts as the dao layer
such as

 Class Student{
     int id;
     School school;
     List<String> courses;
     List<Teacher> teachers;
     Map<String, List<Integer>> courseScores;
 }
 
 School TeacherPO
 

Design a table in mysql, how to design the corresponding fields of school, teachers,courses,courseScores? Do school and teacher use school_id, teacher_id foreign keys directly? What about courses, courseScores?

Mar.28,2021

field name, you can do the field according to the words you can understand at a glance. This is not limited, and it is not recommended that you have no choice but to use foreign keys. The constraint is too strong, which will lead to problems or restrictions in your other operations.


teachers child table
courseScores, is converted to json and a field is saved.

Menu