假設:
20名老師:T01, T02, ... , T20
8間教室:C01, C02, ... , C08
1.
Teacher.java
int id;
String teacherName;
2.
ClassRoom.java
int id;
String roomName;
3.
TCRelt.java (Teacher_ClassRoom_Relation 的縮寫)
int id;
int teacher_id;
int room_id;
然後寫 method
public List<ClassRoom> findClassRoomByTeacher(Teacher teacher){};
public List<Teacher> findTeacherByClassRoom(ClassRoom){};
多對多的問題先簡化成一對多,然後再求解,比較好思考。
不知道有沒有回覆到你的問題。