CREATE TABLE `micro_student` ( `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '用户id', `name` varchar(10) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '名称', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='学生表';
INSERT INTO `micro_serve`.`micro_student`(`id`, `name`) VALUES (1, '张三'); INSERT INTO `micro_serve`.`micro_student`(`id`, `name`) VALUES (2, '李四'); INSERT INTO `micro_serve`.`micro_student`(`id`, `name`) VALUES (3, '赵五');
CREATE TABLE `micro_subject` ( `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', `name` varchar(20) NOT NULL DEFAULT '' COMMENT '课程名称', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB COMMENT='课程表';
insert into `micro_subject`(`name`) values ('语文'),('数学'),('英语');
CREATE TABLE `micro_student_subject` ( `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', `student_id` int unsigned NOT NULL DEFAULT '0' COMMENT '学生id', `subject_id` int unsigned NOT NULL DEFAULT '0' COMMENT '课程id', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB COMMENT='学生课程中间表';
insert into `micro_student_subject`(`student_id`,`subject_id`) values (1,1),(1,2),(1,3),(2,1),(2,2),(3,1),(3,3);
|