发表于: 2018-03-05 17:10:53

4 728


今天完成的事情:

1.整理业务模型,确定几个对象之间的关系。

整理分析出一下三个对象:学员(student)、师兄(brother)、课程(lesson)

它们之间有以下关系:

一个学员有一个指导师兄,一个指导师兄可以指导多个学员(应该是这样的),学员与师兄的关系就是一对多;

一个学员只能选择一种课程,一种课程可以被多个学员选择,学员与课程的关系是一对多;

2.创建学员表

create database itxiuzhen;

use itxiuzhen;

drop table if exists `student`;

create table `student`(

stu_id int(10) not null AUTO_INCREMENT,

create_at datetime not null default current_timestamp on update current_timestamp comment '创建时间',

update_at datetime not null default current_timestamp on update current_timestamp comment '更新时间',

stu_name varchar(10) not null comment '姓名',

QQ varchar(20) not null unique comment 'QQ号',

lesson_type varchar(10) not null comment '课程类型',

admission_time datetime not null default current_timestamp on update current_timestamp not null comment '入学时间',

graduated_school varchar(20) not null comment '毕业院校',

student_id varchar(20) not null unique comment '线上学号',

dialy_link varchar(200) not null unique comment '日报链接',

wish varchar(100) not null comment '愿望',

brother_id int(10) not null comment '师兄',

hear_from varchar(10) not null comment '从何处了解',

primary key(stu_id)

)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


改:创建时间不更新,入学时间不更新

3.插入最新学员数据

insert into student values('1',default,default,'金立剑','867178942','前端工程师',default,'北京印刷学院','235班5171','http://www.jnshu.com/daily/49287?dailyType=others&total=11&page=1&uid=21077&sort=0&orderBy=3','如果我不能在IT特训营拼尽全力,为自己以后的修行路上打好基础,就让我变胖2斤!','1','知乎');


根据姓名查询

  4.修改报名宣言

update student set wish = '老大最帅‘ where stu_id = 1;

5.导入导出

c:\Users\dwk\Desktop>mysqldump -uroot -p itxiuzhen student > student.sql      导出sql

mysql> source c:\Users\dwk\Desktop\student.sql      导入sql

6.插入索引


思考一下还应该给哪些数据建索引?过一段时间来回答

7.插入数据

建立索引后会加快sql语句执行吗?我需要了解更多sql知识


明天要做的事:

学习索引知识



返回列表 返回列表
评论

    分享到