From 73b5d76fccf59acd1810ae50b0f1d035ed7da2cf Mon Sep 17 00:00:00 2001 From: tangent-heng <72395679+tangent-heng@users.noreply.github.com> Date: Tue, 8 Feb 2022 19:41:53 +0800 Subject: [PATCH 1/2] Update database experience docs for bigdata Update database experience docs for bigdata --- .../cse/bigdata/Database/experiment1.md | 253 +++++++++ .../cse/bigdata/Database/experiment2.md | 509 ++++++++++++++++++ 2 files changed, 762 insertions(+) create mode 100644 docs/faculty/cse/bigdata/Database/experiment1.md create mode 100644 docs/faculty/cse/bigdata/Database/experiment2.md diff --git a/docs/faculty/cse/bigdata/Database/experiment1.md b/docs/faculty/cse/bigdata/Database/experiment1.md new file mode 100644 index 00000000..ad953e82 --- /dev/null +++ b/docs/faculty/cse/bigdata/Database/experiment1.md @@ -0,0 +1,253 @@ +## 数据库实验 + + + +### 【实验项目一】 + +**实验内容** + +(一)创建以下六张表,有如下要求: 本次实验100分 + +1)创建后面给出的这6个表(20分)。 + +1)用不同的方法创建约束;2)查看和删除约束;(3)创建、删除默认和规则 (3*5分) + +1)掌握主键约束的特点和用法;2)掌握惟一性约束的用法;3)掌握默认约束和默认对象的用法;4)掌握CHECK约束和规则对象的用法;5)掌握利用主键与外键约束实现参照完整性的方法(5*5分)。 + +1)增加一个字段;2)删除一个字段; 3)增加一个约束; 4)修改字段的数据类型(4*5分); + +1)创建索引;2)重建索引(2*5分)。 + +\1) 创建视图; 2)删除视图(2*5分)。 + +表结构按照显示的数据由读者自行设定,并按下表显示的数据录入至相关表中。 + +读者信息表 + +| 借书证号 | 姓名 | 性别 | 出生日期 | 借书量 | 工作单位 | 电话 | E-mail | +| -------- | ------ | ---- | ---------- | ------ | ---------- | -------- | -------------- | +| 29307142 | 张晓露 | 女 | 1989-02-1 | 2 | 管理信息系 | 85860126 | zxl@163.com | +| 36405216 | 李阳 | 男 | 1988-12-26 | 1 | 航海系 | 85860729 | ly@sina.com.cn | +| 28308208 | 王新全 | 男 | 1988-04-25 | 1 | 人文艺术系 | 85860618 | wxq@yahoo.cn | +| 16406236 | 张继刚 | 男 | 1989-08-18 | 1 | 轮机工程系 | 85860913 | zjg@163.com | +| 16406247 | 顾一帆 | 男 | 1981-12-30 | | 轮机工程系 | 85860916 | gyf@yahoo.cn | + +借还明细表 + +| 借书证号 | 图书编号 | 借/还 | 借书日期 | 还书日期 | 数量 | 工号 | +| -------- | -------- | ----- | ---------- | ---------- | ---- | ------ | +| 29307142 | 07108667 | 还 | 2008-03-28 | 2008-04-14 | 1 | 002016 | +| 29307142 | 99011818 | 借 | 2008-04-27 | | 1 | 002016 | +| 36405216 | 07410802 | 借 | 2008-04-27 | | 1 | 002018 | +| 29307142 | 07410298 | 借 | 2008-04-28 | | 1 | 002018 | +| 36405216 | 00000746 | 还 | 2008-04-29 | 2008-05-09 | 1 | 002016 | +| 28308208 | 07410139 | 借 | 2008-05-10 | | 1 | 002019 | +| 16406236 | 07410139 | 借 | 2008-05-11 | | 1 | 002017 | + +图书类别 + +| 类别号 | 图书类别 | +| ------ | ---------- | +| H31 | 英语 | +| I267 | 当代作品 | +| TP312 | 程序语言 | +| TP393 | 计算机网络 | +| U66 | 船舶工程 | + +图书借阅明细表 + +| 图书编号 | 图书名称 | 借书证号 | 借出日期 | 归还日期 | 库存数 | +| -------- | --------------- | -------- | ---------- | -------- | ------ | +| 99011818 | 文化苦旅 | 29307142 | 2008-04-27 | | 14 | +| 07410802 | 航海英语 | 36405216 | 2008-04-27 | | 24 | +| 07410298 | C++程序设计语言 | 29307142 | 2008-04-28 | | 14 | +| 07410139 | 艺海潮音 | 28308208 | 2008-05-10 | | 18 | +| 07410139 | 艺海潮音 | 16406236 | 2008-05-11 | | 17 | + +工作人员 + +| 工号 | 姓名 | 性别 | 出生日期 | 联系电话 | E-mail | +| ------ | ------ | ---- | ---------- | -------- | -------------- | +| 002016 | 周学飞 | 男 | 1971-05-03 | 85860715 | zxf@163.com | +| 002017 | 李晓静 | 女 | 1979-09-15 | 85860716 | lj@163.com | +| 002018 | 顾彬 | 男 | 1972-04-25 | 85860717 | gb@yahoo.cn | +| 002019 | 陈欣 | 女 | 1968-11-03 | 85860718 | cx@sina.com.cn | + +图书明细表 + +| 类别号 | 图书编号 | 图书名称 | 作者 | 出版社 | 定价 | 购进日期 | 购入数 | 复本数 | 库存数 | +| ------ | -------- | ------------------ | ------ | ------------------ | ---- | ---------- | ------ | ------ | ------ | +| I267 | 99011818 | 文化苦旅 | 余秋雨 | 知识出版社 | 16 | 2000-03-19 | 8 | 15 | 14 | +| TP312 | 00000476 | Delphi高级开发指南 | 坎图 | 电子工业出版社 | 80 | 2000-03-19 | 15 | 15 | 15 | +| U66 | 01058589 | 船舶制造基础 | 杨敏 | 国防工业出版社 | 19 | 2001-07-15 | 20 | 20 | 20 | +| I267 | 07410139 | 艺海潮音 | 李叔 | 江苏文艺出版社 | 19 | 2007-04-12 | 15 | 20 | 18 | +| TP312 | 07410298 | C++程序设计 | 成颖 | 东南大学出版社 | 38 | 2007-05-08 | 10 | 15 | 14 | +| H31 | 07410802 | 航海英语 | 陈宏权 | 武汉工业大学出版社 | 42 | 2007-10-20 | 25 | 25 | 24 | +| H31 | 07108667 | 大学英语学习辅导 | 姜丽蓉 | 北京理工大学出版社 | 23.5 | 2008-02-06 | 25 | 25 | 25 | +| TP393 | 07410810 | 网络工程实用教程 | 汪新民 | 北京大学出版社 | 34.8 | 2008-08-21 | 10 | 15 | 15 | + + + + +**实验代码** + + +```sql +--【实验项目一】数据表, 索引, 视图创建, 修改,删除的设计与完整性约束 + +/* 借书证号 姓名 性别 出生日期 借书量 工作单位 电话 E-mail + 29307142 张晓露 女 1989-02-1 2 管理信息系 85860126 zxl@163.com + 36405216 李阳 男 1988-12-26 1 航海系 85860729 ly@sina.com.cn + 28308208 王新全 男 1988-04-25 1 人文艺术系 85860618 wxq@yahoo.cn + 16406236 张继刚 男 1989-08-18 1 轮机工程系 85860913 zjg@163.com + 16406247 顾一帆 男 1981-12-30 null 轮机工程系 85860916 gyf@yahoo.cn */ + +drop table 读者信息表 + +create table 读者信息表( +读书证号 char(20) , +姓名 char(20) not null, +性别 char(10), +出生日期 datetime, +借书量 int , +工作单位 char(20), +电话 char(20), +Email char(30) +constraint a unique(电话), +constraint c primary key(读书证号), +constraint b check (借书量>0 and 借书量<60) +) + +alter table 读者信息表 add constraint d unique(电话) +alter table 读者信息表 drop constraint b + + + +select * from 读者信息表 + +sp_help 读者信息表 + +insert into 读者信息表 values('29307142','张晓露','女','1989-02-1',2,'管理信息系','85860126','zxl@163.com') +insert into 读者信息表 values('36405216','李阳','男','1988-12-26',1,'航海系','85860729','ly@sina.com.cn') +insert into 读者信息表 values('28308208','王新全','男','1988-04-25',1,'人文艺术系','85860618','wxq@yahoo.cn') +insert into 读者信息表 values('16406236','张继刚','男','1989-08-18',1,'轮机工程系','85860913','zjg@163.com') +insert into 读者信息表 values('16406247','顾一帆','男','1981-12-30',null,'轮机工程系','85860916','gyf@yahoo.cn') + +--------------------------------------- + + +drop table 工作人员 + +create table 工作人员( +工号 char(20) primary key, +姓名 char(10) not null, +性别 char(5), +出生日期 date, +联系电话 char(30) default'00000000', +Mail char(30) +); +----------------------------------- + + +create table 图书类别( +类别号 char(20) primary key, +图书类别 char(20) not null +); + +select * from 图书类别 + +insert into 图书类别 values ('H31','英语'); +insert into 图书类别 values ('I267','当代作品'); +insert into 图书类别 values ('TP312','程序语言'); +insert into 图书类别 values ('TP393','计算机网络'); +insert into 图书类别 values ('U66','船舶工程'); + +---------------------------------- +create table 图书明细表( +类别号 char(20) references 图书类别(类别号),--两种外码创建方式 +图书编号 char(20) primary key, +图书名称 char(30) not null, +作者 char(20), +出版社 char(30), +定价 int, +购进日期 date, +购入数 int, +复本数 int, +库存数 int +--foreign key(类别号) references 图书类别(类别号) +); + +alter table 图书明细表 +add constraint UQ_图书编号 +unique (图书编号); + +select * from 图书明细表 +insert into 图书明细表 values ('I267','99011818','文化苦旅','余秋雨','知识出版社',16,'2000-03-19',8,15,14); +insert into 图书明细表 values ('TP312','00000476','Delphi高级开发指南','坎图','电子工业出版社',80,'2000-03-19',15,15,15); +insert into 图书明细表 values ('U66','01058589','船舶制造基础','杨敏','国防工业出版社',19,'2001-07-15',20,20,20); +insert into 图书明细表 values ('I267','07410139','艺海潮音','李叔','江苏文艺出版社',19,'2007-04-12',15,20,18); +insert into 图书明细表 values ('TP312','07410298','C++程序设计','成颖','东南大学出版社',38,'2007-05-08',10,15,14); +insert into 图书明细表 values ('H31','07410802','航海英语','陈宏权','武汉工业大学出版社',42,'2007-10-20',25,25,24); +insert into 图书明细表 values ('H31','07108667','大学英语学习辅导','姜丽蓉','北京理工大学出版社',23.5,'2008-02-06',25,25,25); +insert into 图书明细表 values ('TP393','07410810','网络工程实用教程','汪新民','北京大学出版社',34.8,'2008-08-21',10,15,15); +update 图书明细表 set 图书编号='00000746' where 图书名称='Delphi高级开发指南'; + +----------------------------------------- + +create table 借还明细表( +读书证号 char(20) references 读者信息表(读书证号), +图书编号 char(20) references 图书明细表(图书编号), +借还 char(5) check (借还 in('借','还' ) ), +借书日期 datetime, +还书日期 datetime, +数量 int, +工号 char(20) +) + +insert into 借还明细表 values ('29307142','07108667','还','2008-03-28','2008-04-14',1,'002016'); +insert into 借还明细表 values ('29307142','99011818','借','2008-04-27',NULL,1,'002016'); +insert into 借还明细表 values ('36405216','07410802','借','2008-04-27',NULL,1,'002018'); +insert into 借还明细表 values ('29307142','07410298','借','2008-04-28','',1,'002018'); +insert into 借还明细表 values ('36405216','00000746','还','2008-04-29','2008-05-09',1,'002016'); +insert into 借还明细表 values ('28308208','07410139','借','2008-05-10','',1,'002019'); +insert into 借还明细表 values ('16406236','07410139','借','2008-05-11','',1,'002017'); + +update 借还明细表 set 还书日期=NULL where 图书编号='07410298'; +update 借还明细表 set 还书日期=NULL where 图书编号='07410802'; +update 借还明细表 set 还书日期=null where 读书证号='16406236' and 图书编号='07410139'; +update 借还明细表 set 还书日期=null where 读书证号='28308208' and 图书编号='07410139'; + +select * from 借还明细表 + +----------------------------------- + + +create table 图书借阅明细表( +图书编号 char(20) references 图书明细表(图书编号), +图书名称 char(30) not null, +读书证号 char(20) references 读者信息表(读书证号), +借出日期 datetime, +归还日期 datetime, +库存数 int not null, +); + +insert into 图书借阅明细表 values('99011818','文化苦旅','29307142','2008-04-27','',14); +insert into 图书借阅明细表 values('07410802','航海英语','36405216','2008-04-27',NULL,24); +insert into 图书借阅明细表 values('07410298','C++程序设计语言','29307142','2008-04-28','',14); +insert into 图书借阅明细表 values('07410139','艺海潮音','28308208','2008-05-10','',18); +insert into 图书借阅明细表 values('07410139','艺海潮音','16406236','2008-05-11','',17); + +select * from 图书借阅明细表 +---------------------------- + +sp_helpconstraint 图书借阅明细表 + +create index a_idx on 图书借阅明细表(库存数) +alter index a_idx on 图书借阅明细表 rebuild +drop index a_idx on 图书借阅明细表 + +create view a_view +as select * from 图书借阅明细表 + +select * from a_view +``` diff --git a/docs/faculty/cse/bigdata/Database/experiment2.md b/docs/faculty/cse/bigdata/Database/experiment2.md new file mode 100644 index 00000000..7ae34490 --- /dev/null +++ b/docs/faculty/cse/bigdata/Database/experiment2.md @@ -0,0 +1,509 @@ +## 数据库实验 + + + +### 【实验项目二】 + +**实验内容** + +本次实验共100分,做对一个给4分。以随机抽查现场做为准 + +设如下四个表,先创建表, 插入数据, 然后做后面的查询: + +student (学生信息表) + +sno sname sex birthday class + +108 曾华男09/01/77 95033 + +105 匡明男10/02/75 95031 + +107 王丽女01/23/76 95033 + +101 李军男02/20/76 95033 + +109 王芳女02/10/75 95031 + +103 陆军男06/03/74 95031 + + + +teacher(老师信息表) + +tno tname sex birthday prof depart + +804 李诚男12/02/58 副教授计算机系 + +856 李旭男03/12/69 讲师电子工程系 + +825 王萍女05/05/72 助教计算机系 + +831 刘冰女08/14/77 助教电子工程系 + + + +course(课程表) + +cno cname tno + +3-105 计算机导论825 + +3-245 操作系统804 + +6-166 数字电路856 + +9-888 高等数学825 + + + +score(成绩表) + +sno cno degree + +103 3-245 86 + +105 3-245 75 + +109 3-245 68 + +103 3-105 92 + +105 3-105 88 + +109 3-105 76 + +101 3-105 64 + +107 3-105 91 + +108 3-105 78 + +101 6-166 85 + +107 6-166 79 + +108 6-166 81 + +请写出下列查询语句并给出结果 + +1、列出student表中所有记录的sname、sex和class列。答案 + +2、显示教师所有的单位即不重复的depart列。 + +3、显示学生表的所有记录。 + +4、显示score表中成绩在60到80之间的所有记录。 + +5、显示score表中成绩为85,86或88的记录。 + +6、显示student表中“95031”班或性别为“女”的同学记录。 + +7、以class降序显示student表的所有记录。 + +8、以cno升序、degree降序显示score表的所有记录。 + +9、显示“98031”班的学生人数。 + +10、显示score表中的最高分的学生学号和课程号。 + +11、显示“3-105”号课程的平均分。 + +12、显示score表中至少有5名学生选修的并以3开头的课程号的平均分数。 + +13、显示最低分大于70,最高分小于90 的sno列。 + +14、显示所有学生的 sname、 cno和degree列。 + +15、显示所有学生的 sname、 cname和degree列。 + +16、列出“95033”班所选课程的平均分。 + +17、显示选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录。 + +18、显示score中选修多门课程的同学中分数为非最高分成绩的记录。 + +19、显示成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录。 + +20、显示出和学号为“108”的同学同年出生的所有学生的sno、sname和 birthday列。 + +21、显示“张旭”老师任课的学生成绩。 + +22、显示选修某课程的同学人数多于5人的老师姓名。 + +23、显示“95033”班和“95031”班全体学生的记录。 + +24、显示存在有85分以上成绩的课程cno。 + +25、显示“计算机系”老师所教课程的成绩表。 + +26、显示“计算机系”和“电子工程系”不同职称的老师的tname和prof。 + +27、显示选修编号为“3-105”课程且成绩至少高于“3-245”课程的同学的cno、sno和degree,并按degree从高到低次序排列。 + +28、显示选修编号为“3-105”课程且成绩高于“3-245”课程的同学的cno、sno和degree。 + +29、列出所有任课老师的tname和depart。 + +30、列出所有未讲课老师的tname和depart。 + +31、列出所有老师和同学的 姓名、性别和生日。 + +*32、检索所学课程包含学生“103”所学课程的学生学号。 + +*33、检索选修所有课程的学生姓名。 + + + +**实验代码** + +```sql +/* +student (学生信息表) +sno sname sex birthday class +108 曾华男09/01/77 95033 +105 匡明男10/02/75 95031 +107 王丽女01/23/76 95033 +101 李军男02/20/76 95033 +109 王芳女02/10/75 95031 +103 陆军男06/03/74 95031 +*/ + +create table student +( +sno char(10) primary key, --主码 +sname char(10) not null, +sex char(2), +birthday datetime, +class char(10) +) + +insert into student values('108','曾华','男','77/09/01','95033') +insert into student values('105','匡明','男','75/10/12','95031') +insert into student values('107','王丽','女','76/01/23','95033') +insert into student values('101','李军','男','77/02/20','95033') +insert into student values('109','王芳','女','75/02/10','95031') +insert into student values('103','陆军','男','74/06/03','95031') + +select * from student + +/* +teacher(老师信息表) +tno tname sex birthday prof depart +804 李诚男12/02/58 副教授计算机系 +856 李旭男03/12/69 讲师电子工程系 +825 王萍女05/05/72 助教计算机系 +831 刘冰女08/14/77 助教电子工程系 +*/ + +create table teacher +( +tno char(10) primary key, --主码 +tname char(10) not null, +sex char(2), +birthday datetime, +prof char(15), +depart char(25) +) + +insert into teacher values('804','李诚','男','58/12/02','副教授','计算机系') +insert into teacher values('856','李旭','男','69/03/12','讲师','电子工程系') +insert into teacher values('825','王萍','女','72/05/05','助教','计算机系') +insert into teacher values('831','刘冰','女','77/08/14','助教','电子工程系') + +select * from teacher + +/* +course(课程表) +cno cname tno +3-105 计算机导论825 +3-245 操作系统804 +6-166 数字电路856 +9-888 高等数学825 +*/ + +create table cource +( +cno char(15) primary key, --主码 +cname char(15) not null, +tno char(10) not null +) + +insert into cource values('3-105','计算机导论','825') +insert into cource values('3-245','操作系统','804') +insert into cource values('6-166','数字电路','856') +insert into cource values('9-888','高等数学','825') + +select * from cource + +/* +score(成绩表) +sno cno degree +103 3-245 86 +105 3-245 75 +109 3-245 68 +103 3-105 92 +105 3-105 88 +109 3-105 76 +101 3-105 64 +107 3-105 91 +108 3-105 78 +101 6-166 85 +107 6-166 79 +108 6-166 81 +*/ + +create table score +( +sno char(10) not null, +cno char(15) not null, +degree int +) + +insert into score values('103','3-245','86') +insert into score values('105','3-245','75') +insert into score values('109','3-245','68') +insert into score values('103','3-105','92') +insert into score values('105','3-105','88') +insert into score values('109','3-105','76') +insert into score values('101','3-105','64') +insert into score values('107','3-105','91') +insert into score values('108','3-105','78') +insert into score values('101','6-166','85') +insert into score values('107','6-166','79') +insert into score values('108','6-166','81') + +select * from score + + + + + +select * from student +select * from cource +select * from score +select * from teacher + + + +--1、列出student表中所有记录的sname、sex和class列。 + +select sname,sex,class from student + +--2、显示教师所有的单位即不重复的depart列。 + +select distinct depart from teacher + +--3、显示学生表的所有记录。 + +select * from student + +--4、显示score表中成绩在60到80之间的所有记录。 + +select * from score where degree between 60 and 80 + +select * from score where degree >=60 and degree <= 80 + +--5、显示score表中成绩为85,86或88的记录。 + +select * from score where degree in (85,86,88) + +select * from score where degree =85 or degree =86 or degree =88 + +--6、显示student表中“95031”班或性别为“女”的同学记录。 + +select * from student where class ='95031' or sex='女' + +--7、以class降序显示student表的所有记录。 + +select * from student order by class desc + +--8、以cno升序、degree降序显示score表的所有记录。 + +select * from score order by cno asc,degree desc + +--9、显示“95031”班的学生人数。 + +select * from student + +select * from student where class='95031' + +--10、显示score表中的最高分的学生学号和课程号。 + +select sno,cno from score where degree >= all(select degree from score) + +select sno,cno from score where degree >= (select max(degree) from score) + +select top 1 with ties sno,cno from score order by degree --可能有相同分,使用with ties + +--11、显示“3-105”号课程的平均分。 + +select * from score + +select avg(degree) '3-105号课程平均分' +from score group by cno having cno='3-105' + +select avg(degree) '3-105号课程平均分' +from score where cno='3-105' group by cno + +--12、显示score表中至少有5名学生选修的并以3开头的课程号的平均分数。 + +select * from score + +select avg(degree) 平均分,count(*) 选课人数 from score where cno like '3%' group by cno having count(*)>=5 + +--13、显示最低分大于70,最高分小于90 的sno列。 + +select sno from score group by sno having min(degree) > 70 and max(degree) < 90 + +--14、显示所有学生的 sname、 cno和degree列。 + +select sname, cno, degree from student, score where student.sno=score.sno + +--15、显示所有学生的 sname、 cname和degree列。 + +select sname, cname, degree from student, score,cource where student.sno=score.sno and cource.cno=score.cno + +--16、列出“95033”班所选课程的平均分。 + +select * from student + +select avg(degree) from score + where sno in (select sno from student where class = '95033') + +--17、显示选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录。 + +select * from score + +select * from student + where sno in ( + select sno from score + where cno='3-105' and degree >( select degree from score where sno='109' and cno='3-105' ) + ) + +--18、显示score中选修多门课程的同学中分数为非最高分成绩的记录。 + +select a.sno, a.degree, a.cno from score a, score b +where a.sno=b.sno and a.degree( + select degree from score where sno='109' and cno='3-105' +) + +--20、显示出和学号为“108”的同学同年出生的所有学生的sno、sname和 birthday列。 + +select * from student + + +select sno, sname, birthday from student + where sno!='108' and year(birthday) = (select year(birthday) from student where sno='108') + +--21、显示“李旭”老师任课的学生成绩。 + +select * from cource +select * from teacher +select * from score + +select sno,degree from score where cno in( + select cno from cource + where tno = (select tno from teacher where tname='李旭') +) + +--22、显示选修某课程的同学人数多于5人的老师姓名。 + +select tname from teacher where tno in( + select tno from cource where cno in( + select cno from score group by cno having count(sno)>5 + ) +) + +--23、显示“95033”班和“95031”班全体学生的记录。 + +select * from student where class in('95033','95031') + +select * from student where class = '95033' or class = '95031' + +--24、显示存在有85分以上成绩的课程cno。 + +select cno from score group by cno having max(degree)>=85 + +--25、显示“计算机系”老师所教课程的成绩表。 + +select * from score where cno in( + select cno from cource where tno in( + select tno from teacher where depart = '计算机系' + ) +) + +select * from score,cource,teacher + where score.cno=cource.cno and cource.tno= teacher.tno and teacher.depart = '计算机系' + + +--26、显示“计算机系”和“电子工程系”不同职称的老师的tname和prof。 + +select * from teacher + +select tname , prof from teacher +where depart='计算机系' and prof not in +(select prof from teacher where depart='电子工程系') + + +--27、显示选修编号为“3-105”课程且成绩至少高于“3-245”课程的同学的cno、sno和degree,并按degree从高到低次序排列。 + +select cno, sno, degree from score where sno in( + select sno from score where cno='3-105' and degree>(select min(degree) from score where cno='3-245') +) order by degree desc + +--28、显示选修编号为“3-105”课程且成绩高于“3-245”课程的同学的cno、sno和degree。 + +select cno, sno, degree from score where sno in( + select sno from score where cno='3-105' and degree>(select min(degree) from score where cno='3-245') +) + +--29、列出所有任课老师的tname和depart。 + +select tname,depart from teacher a +where exists(select * from cource b where a.tno=b.tno) + +select tname,depart from teacher where tno in (select tno from cource) + + +--30、列出所有未讲课老师的tname和depart。 + +select tname,depart from teacher where tno not in (select tno from cource) + +--31、列出所有老师和同学的 姓名、性别和生日。 + +select sname 姓名 ,sex 性别,birthday 生日 from student +union +select tname 姓名,sex 性别,birthday 生日 from teacher + +--*32、检索所学课程包含学生“103”所学课程的学生学号。 + +Select sno from score,(select cno from score where sno='103')course103 +where score.cno=course103.cno +group by sno having count(score.cno)=(select count(cno) from score where sno='103') + + + +select * from student +select * from score + +select sno from score x +where not exists + (select * from score y + where y.sno=103 and + not exists + (select * from score z + where z.sno=x.sno and z.cno=y.cno) ) + + +--*33、检索选修所有课程的学生姓名。 +select student.sname from student + where not exists (select * from cource + where not exists + (select * from score + where student.sno=score.sno and cource.cno=score.cno)) +``` + From 122de7c86099289a1524c4688a2eb7729104c57c Mon Sep 17 00:00:00 2001 From: tangent-heng <72395679+tangent-heng@users.noreply.github.com> Date: Tue, 8 Feb 2022 19:48:00 +0800 Subject: [PATCH 2/2] Update notes table by adding database Update notes table by adding database --- docs/faculty/cse/bigdata/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/faculty/cse/bigdata/README.md b/docs/faculty/cse/bigdata/README.md index 473804e9..fecf7e41 100644 --- a/docs/faculty/cse/bigdata/README.md +++ b/docs/faculty/cse/bigdata/README.md @@ -4,6 +4,8 @@ - [数据科学与大数据技术](#数据科学与大数据技术) - [专业笔记及实验](#专业笔记及实验) + - [第三学期](#第三学期) + - [数据库原理](#数据库原理) - [第五学期](#第五学期) - [R语言](#r语言) - [深度学习](#深度学习) @@ -15,6 +17,11 @@ ## 专业笔记及实验 +### 第三学期 + +#### 数据库原理 +- [实验报告](Database/) + ### 第五学期 #### R语言