mybatis学习篇

来源:互联网 发布:程序员联合开发网 编辑:程序博客网 时间:2024/05/26 19:18

mybatis学习笔记(深入浅出mybatis技术原理与实战)

以下是mybatis的数据库表sql.之后的学习都以这几张表为基础了

Drop table if exists t_role;
Drop table if exists t_user;
Drop table if exists t_user_role;
Drop table if exists t_lecture;
Drop table if exists t_lecture;
Drop table if exists t_student;
Drop table if exists t_student_health_female;
Drop table if exists t_student_health_male;
Drop table if exists t_student_lecture;
Drop table if exists t_student_selfcard;

Create table t_role (
id int(20) not null auto_increment comment ‘编号’,
role_name varchar(60) not null comment ‘角色名称’,
note varchar(1024) default null comment ‘备注’,
primary key (id)
) engine=innodb default charset=utf8;

Create table t_user (
id bigint(20) not null auto_increment comment ‘编号’,
user_name varchar(60) not null comment ‘用户名称’,
cnname varchar(60) not null comment ‘姓名’,
sex tinyint(3) not null comment ‘性别’,
mobile varchar(20) not null comment ‘手机号码’,
email varchar(60) default null comment ‘电子邮箱’,
note varchar(1024) default null comment ‘备注’,
primary key (id)
) engine=innodb default charset=utf8;

Create table t_user_role (
user_id bigint(20) not null comment ‘用户编号’,
role_id int(20) not null comment ‘角色编号’,
primary key (user_id,role_id)
);
Alter table t_user_role add constraint fk_reference_1 foreign key (user_id)
References t_user (id) on delete restrict on update restrict;
Alter table t_user_role add constraint fk_reference_2 foreign key (role_id)
References t_role (id) on delete restrict on update restrict;

Create table t_lecture(
id int (20) not null auto_increment comment ‘编号’,
lecture_name varchar (60) not null comment ‘课程名称’,
note varchar (1024) comment ‘备注’,
primary key (id)
);

Create table t_student (
id int (20) not null auto_increment comment ‘编号’,
cnname varchar (60) not null comment ‘学生姓名’,
sex tinyint (4) not null comment ‘性别’,
selfcard_no int (20) not null comment ‘学生证号’,
note varchar (1024) comment ‘备注’,
primary key (id)
);

Create table t_student_health_female(
id int (20) not null auto_increment comment ‘编号’,
student_id varchar(60) not null comment ‘学生编号’,
check_date varchar(60) not null comment ‘检查日期’,
heart varchar (60) not null comment ‘心’,
liver varchar (60) not null comment ‘肝’,
spleen varchar (60) not null comment ‘脾’,
lung varchar (60) not null comment ‘肺’,
kidney varchar (60) not null comment ‘肾’,
uterus varchar (60) not null comment ‘子宫’,
note varchar (1024) null comment ‘备注’,
primary key (id)
);

Create table t_student_health_male(
id int (20) not null auto_increment comment ‘编号’,
student_id varchar(60) not null comment ‘学生编号’,
check_date varchar(60) not null comment ‘检查日期’,
heart varchar (60) not null comment ‘心’,
liver varchar (60) not null comment ‘肝’,
spleen varchar (60) not null comment ‘脾’,
lung varchar (60) not null comment ‘肺’,
kidney varchar (60) not null comment ‘肾’,
prostate varchar (60) not null comment ‘前列腺’,
note varchar (1024) null comment ‘备注’,
primary key (id)
);

Create table t_student_lecture(
id int(20) not null auto_increment comment ‘编号’,
student_id int(20) not null comment ‘学生编号’,
lecture_id int(20) not null comment ‘课程编号’,
grade decimal(16,2) not null comment ‘评分’,
note varchar(1024) comment ‘备注’,
primary key(id)
);

Create table t_student_selfcard(
id int(20) not null auto_increment comment ‘编号’,
student_id int (20) not null comment ‘学生编号’,
native varchar (60) not null comment ‘籍贯’,
issue_date date not null comment ‘发证日期’,
end_date date not null comment ‘结束日期’,
note varchar (1024) comment ‘备注’,
primary key (id)
);

0 0
原创粉丝点击