与一对多的多端一致,多对多两表的配置一致

    多对多关系三个表格,由于中间表只存储了关系,没有必要存储这个domain,每一个对象中分别存储一个集合 集合里面存储跟自己有关的另一些对象

    需求 :给老师的tid 查询老师的信息 + 所教的所有学生信息
    需求:给学生的sis 查询学生的信息 + 所听的所有老师的课程

    #分别设置两个列的外键约束
    alter table tea_stu add constraint fk_teacher foreign key(tid) references teacher(tid);
    alter table tea_stu add constraint fk_student foreign key(sid) references student(sid);

    #设置联合主键
    alter table tea_stu add constraint pk_tea_stu primary key(tid,sid);