老师您好,
这是会员关联课程的表:
drop table if exists member_course;
create table member_course (id char(8) not null default ‘’ comment ‘id’,member_id char(8) not null comment ‘会员id’,course_id char(8) not null comment ‘课程id’,at datetime(3) not null comment ‘报名时间’,
primary key (id),
unique key member_course_unique (member_id, course_id)
) engine=innodb default charset=utf8mb4 comment=‘会员课程报名’;
一个会员可以报名多个课程,一个课程可以被多名会员报名,应该是一个多对多的关系。老师这里使用:unique key member_course_unique (member_id, course_id),指的是不能出现课程id与会员id组合同时重复是吗?
一条记录中a会员关联了a1课程,那么这个组合就不能在表中再次出现,是这样的意思吗?
这是复合索引吗?
unique key和index关键字建立的索引有什么区别呢?
给老师添麻烦了。