数据库day1作业

这篇博客介绍了数据库day1的作业,包括设计学院表、教师表和课程表,并探讨了这些表之间的关系。作业还涉及了在MySQL中创建表、添加数据的操作,以及对学院表进行数据插入的示例。

数据库day1作业

作业一:

  1. 创建一张学院表(编号、名称、介绍)
  2. 创建一张老师表(工号、姓名、性别、出生日期、职称、研究领域)
  3. 创建一张课程表(编号、名称、课时、学分)

作业二:

想一想,上面的表以及学生表直接有没有什么关系?如果有,是什么样的关系?

作业三:

阅读《MySQL必知必会》一书,尝试给学院表添加3条学院的数据。 —> insert

以下是作业代码:

drop database if exists school;
create database school default charset utf8mb4;
use school;
drop table if exists tb_student;
create table tb_student
(
stu_id int not null comment ‘学号’,
stu_name varchar(20) not null comment ‘姓名’,
stu_sex boolean not null default 1 comment ‘性别’,
stu_birth date comment ‘出生日期’,
primary key (stu_id)
)engine=InnoDB comment ‘学生表’;
alter table tb_student add column stu_addr varchar(200) not null default ‘’ comment ‘家庭住址’;
alter table tb_student modify column stu_sex char(1) not null default ‘男’;
alter table tb_student add constraint ck_student_sex check(stu_sex=‘男’ or stu_sex=‘女’);

create table tb_college
(
college_number int not null comment ‘学院编号’,
college_name varchar(50) not null comment ‘学院名称’,
college_introduction varchar(200) not null comment ‘学院介绍’,
primary key (college_number)
)engine=InnoDB comment ‘学院表’;

create table tb_teacher
(
teacher_number int not null comment ‘老师工号’,
teacher_name varchar(20) not null comment ‘老师姓名’,
teacher_birth date not null comment ‘出生日期’,
teacher_pro varchar(20) not null comment ‘职称’,
teacher_res varchar(50) not null comment ‘研究领域’,
primary key(teacher_number)
)engine=InnoDB comment ‘老师表’;

create table tb_course
(
course_number int not null comment ‘课程编号’,
course_name varchar(20) not null comment ‘课程名称’,
course_hour time not null comment ‘课时’,
course_credit decimal not null comment ‘学分’,
primary key(course_number)
)engine=InnoDB comment ‘课程表’;

insert into tb_college values(
1,‘千锋教育’,‘一群草根奉献着自己的青春年华,为创造一个有真正社会价值的职业教育机构“千锋教育”而奋力拼搏!几十年后,当每一位千锋人回忆在千锋这段历程,相信内心深处是欣慰的。因为我们没有虚度年华,我们一起努力拼搏做了一件非常有意义的事情:帮助更多迷茫的学生实现他们的梦想!’
),
(
2,‘北大青鸟’,‘北京青鸟职业教育科技发展有限公司是为契合国家职业教育改革成立的一家专注于职业教育的教育科技公司。公司以“支持每一位学员成为受人尊重的专业人才”为使命,始终践行“职业教育就是就业教育”的教育本质,坚持帮助学员成功就业,永远是硬道理;始终保持回归职业教育的本真,即坚守“教育为本,师爱为魂”的教育理念,以及“内育职业素养,外塑专业技能”的青鸟校训。’
),
(
3,‘达内教育’,‘达内致力于面向IT互联网行业,培养软件开发工程师、测试工程师、系统管理员、智能硬件工程师、UI设计师、网络营销工程师、会计等职场人才。’
);

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值