中南大学10级数据库技术试题.docx

上传人:b****5 文档编号:7373182 上传时间:2023-01-23 格式:DOCX 页数:10 大小:19.02KB
下载 相关 举报
中南大学10级数据库技术试题.docx_第1页
第1页 / 共10页
中南大学10级数据库技术试题.docx_第2页
第2页 / 共10页
中南大学10级数据库技术试题.docx_第3页
第3页 / 共10页
中南大学10级数据库技术试题.docx_第4页
第4页 / 共10页
中南大学10级数据库技术试题.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

中南大学10级数据库技术试题.docx

《中南大学10级数据库技术试题.docx》由会员分享,可在线阅读,更多相关《中南大学10级数据库技术试题.docx(10页珍藏版)》请在冰豆网上搜索。

中南大学10级数据库技术试题.docx

中南大学10级数据库技术试题

中南大学考试试卷

2010--2011学年下学期时间100分钟

数据库应用基础课程56学时3.5学分考试形式:

闭卷

专业年级:

商学院10级总分100分,占总评成绩70%

注:

请将答案直接写在试卷上!

在本试卷中除特殊说明外数据库系统为SQLSERVER,均采用下列表:

学生信息表Student(NO,NAME,AGE,SEX,CLASS,NA),其字段名分别表示学号(CHAR(4))、姓名(VARCHAR(8))、年龄(INT)、性别(CHAR

(2))、班级(VARCHAR(4))、民族(VARCHAR(18)),主键为NO。

教师信息表T(NO,NAME,sex,ab),其字段名分别表示教师编号(Char(4))、姓名(varchar(8))、性别(char

(2))、职称(Varchar(6)),主键为NO。

课程信息表C(NO,NAME,TNO),其字段名分别表示课程编号(Char(4))、课程名称(VARCHAR(12))、授课教师编号(varchar(4),主键为(NO,TNO)。

学生选课及成绩表SC(NO,CNO,GRADE),其字段名分别表示学号(char(4))、课程编号(char(4)、成绩(int),主键为(NO,CNO)。

在企业管理器中按下列方式录入数据保存。

Student的数据

NO

Name

Age

Sex

CLASS

NA

0101

刘琳

20

1002

汉族

0105

王刚

21

1015

苗族

0102

李晓

22

1015

土家族

0110

张明

NULL

1002

汉族

0108

周冰

21

1015

苗族

2031

NULL

20

1002

汉族

T的数据

NO

Name

Sex

AB

1003

刘瑞

讲师

2020

陈晓

副教授

0102

李斌

教授

C的数据

NO

Name

TNO

2010

数据库技术

1003

2010

数据库技术

0102

2015

高等数学

2020

 

SC的数据

NO

CNO

GRADE

0105

2010

88

0108

2010

90

1010

2010

85

0101

2010

NULL

0105

2015

78

0102

2010

NULL

0110

2015

80

0108

2015

NULL

0102

2015

82

0112

2015

NULL

一、已知属性集U={学号、姓名、性别、年龄、民族、班级编号、班级名称、班长、身份证号、所属学院编号,所属学院名称、宿舍号、家庭住址},写出下列要求的关系模式,并说明理由。

(共10分)

(1)写出U是的一个关系模式,使其具有完全函数依赖关系;

(2)写出U是的一个关系模式,使其具有部分函数依赖关系;

(3)写出U是的一个关系模式,使其具有传递函数依赖关系;

(4)写出U是的一个关系模式,使其具有二个关键字;

(5)写出U是的一个关系模式,使其具有完全函数依赖关系但不具有传递依赖关系。

二、已知某饲料企业的产品出库单下图所示,按下列要求设计满足条件的数据库(即一个或多个表),并说明理由。

(共14分)

A饲料厂产品销售单

销售单位名称

销售单号

产品名称

规格型号

计量单位

单价

数量

金额

总金额

开票人:

发货人:

(1)满足1NF但不满足2NF的数据库(4分);

(2)满足2NF的数据库(4分);

(3)满足3NF的数据库(6分)。

三、判断下列描述或命令是否正确,如果不正确,请在不改变原来命令意义的基础上改正(共30分)

(1)数据库中模式、外模式和模式/内模式映像是唯一的。

当模式改变时,只要修改外模式/模式映像,应用程序不需要修改,这一特性,称为物理独立性。

改为:

数据库中模式、模式/内模式映像是唯一的。

当内模式改变时,只要修改模式/模式映像,应用程序不需要修改,这一特性,称为物理独立性。

 

(2)若F是关系R的外码,它与S的主码相对应,根据参照完整性规则,R中每个元组在F上的取值等于S中某个元组的主码值。

改为:

若F是关系R的外码,它与S的主码相对应,根据参照完整性规则,R中每个元组在F上的取值等于S中某个元组的主码值或为空值。

(3)在一个关系模式中,包含在主关键字中的属性称为主属性,主属性之外的属性称为非主属性。

改为:

在一个关系模式中,包含在关键字中的属性称为主属性,主属性之外的属性称为非主属性。

(4)createviewV_student_SC(学号,姓名,课程编码,成绩)as

Selectstudent.no,student.name,o,sc.gradefromstudenta,scbwherestudent.no=sc.noorderbyo

改为:

reateviewV_student_SC(学号,姓名,课程编码,成绩)as

Selectstudent.no,student.name,sc.no,sc.grade

fromstudent,scwherestudent.no=sc.no

(5)selectstudent.*,o,sc.gradefromstudentrightouterjoinsc,cwherestudent.no=sc.noandc.no=o(注意:

如果认为这命令是错误的,改正时要用到外连接)

改为:

selectstudent.*,o,sc.gradefromstudentrightouterjoinsconstudent.no=sc.no

(6)selectno,classfromstudentwherename=’李%’andnoinselect*fromscwherestudent.no=sc.no

改为:

selectno,classfromstudentwherenamelike'李%'andnoin(selectnofromscwherestudent.no=sc.no)

(7)检索班级平均年龄大于18且为汉族的学生情况的命令为:

selectno,classfromstudentwherenotna=’汉族’orna=’苗族’andavg(age)>18

改为:

selectno,classfromstudentwhereclassin(selectclassfromstudentgroupbyclasshavingavg(age)>18)andna='汉族'

 

(8)selectstudent.no+age,name,sc.*fromstudent,scwherestudent.no=sc.nogroupbyohavingcount(cno)>2

改为:

selectofromstudent,scwherestudent.no=sc.nogroupbyohavingcount(cno)>2

(9)selectno,name,sex,classfromstudentwherena=’汉族’Union

Selectno,name,age,classfromstudentwherena=’苗族’

改为:

selectno,name,sex,classfromstudentwherena='汉族'Union

Selectno,name,sex,classfromstudentwherena='苗族'

(10)selectstudent.no,student.name,o,sc.gradefromc,studentleftouterjoinsconstudent.no=sc.noandc.no=o

改为:

selectstudent.no,student.name,o,sc.grade

fromc,studentleftouterjoinsconstudent.no=sc.nowherec.no=o

 

四、写出下列命令的结果。

(本题18分)

(1)selectno,agefromstudent;

noage

---------------

010120

010222

010521

010821

0110NULL

203120

(所影响的行数为6行)

 

no

age

0101

20

0102

22

0105

21

0108

21

0110

NULL

2031

20

(2)在STUDENT表中对AGE按升序建立索引后,执行下列命令:

selectage,nofromstudent;

age

no

NULL

0110

20

0101

20

2031

21

0105

21

0108

22

0102

(3)select*fromstudentorderbyage,name;

nonameagesexclassna

--------------------------------------------------

0110张明NULL男1002汉族

2031NULL20男1002汉族

0101刘琳20女1002汉族

0105王刚21男1015苗族

0108周冰21女1015苗族

0102李晓22女1015土家族

(所影响的行数为6行)

 

0110

张明

NULL

1002

汉族

2031

NULL

20

1002

汉族

0101

刘琳

20

1002

汉族

0105

王刚

21

1015

苗族

0108

周冰

21

1015

苗族

0102

李晓

22

1015

土家族

(4)selectstudent.no,student.name,student.agefromstudentwhereclass>'1001'

andnoin(selectsc.nofromstudentleftouterjoinsconstudent.no=sc.nowhereoin(selectnofromCwherenamelike'数据库%'))

nonameage

-----------------------

0101刘琳20

0102李晓22

0105王刚21

0108周冰21

(所影响的行数为4行)

 

0101

刘琳

20

0102

李晓

22

0105

王刚

21

0108

周冰

21

(5)selectstudent.no,student.name,student.class,o,sc.gradefromstudentrightouterjoinsconstudent.no=sc.nowhereoin(selectnofromcwheretnoin(selectnofromTwheresex=’女’))andexists(selectclassfromstudentgroupbyclasshavingavg(age)>17)

nonameclasscnograde

--------------------------------

0101刘琳10022010NULL

0102李晓10152010NULL

0105王刚1015201088

0108周冰1015201090

NULLNULLNULL201085

(所影响的行数为5行)

 

no

name

class

cno

grade

0101

刘琳

1002

2010

NULL

0102

李晓

1015

2010

NULL

0105

王刚

1015

2010

88

0108

周冰

1015

2010

90

NULL

NULL

NULL

2010

85

(6)select*fromstudentwhereage>(selectavg(age)fromstudentgroupbyclasshavingavg(age)>20)andnoin(selectnofromscgroupbynohavingavg(grade)>80andcount(cno)>1)

nonameagesexclassna

--------------------------------------------------

0102李晓22女1015土家族

(所影响的行数为1行)

no

name

age

sex

class

na

0102

李晓

22

1015

土家族

(7)selectstudent.no,student.name,student.class,o,sc.gradefromstudent,sc,Cwherestudent.no=sc.noando=c.noandc.name=’数据库技术’orderbysc.grade

nonameclasscnograde

--------------------------------

0101刘琳10022010NULL

0101刘琳10022010NULL

0102李晓10152010NULL

0102李晓10152010NULL

0105王刚1015201088

0105王刚1015201088

0108周冰1015201090

0108周冰1015201090

(所影响的行数为8行)

0101

刘琳

1002

2010

NULL

0101

刘琳

1002

2010

NULL

0102

李晓

1015

2010

NULL

0102

李晓

1015

2010

NULL

0105

王刚

1015

2010

88

0105

王刚

1015

2010

88

0108

周冰

1015

2010

90

0108

周冰

1015

2010

90

(8)selectstudent.class,o,avg(grade)fromstudent,scgroupbystudent.class,ohavingcount(cno)>1

classcno

--------------------

1002201087

1015201087

1002201580

1015201580

(所影响的行数为4行)

1002

2010

87

1015

2010

87

1002

2015

80

1015

2015

80

五、用一条命令完成下列操作(本题18分)

(1)检索少数民族学生的所有课程的成绩;

 

(2)检索没有选择刘老师的数据库技术课程的男同学的情况;

 

(3)检索教数据库技术的各位老师所授班级的平均成绩;

 

(4)删除在STUDENT上建立的名为AB的索引;

 

(5)检索选择了副教授以上(含副教授)职称老师二门以上课程的学生的情况;

 

(6)将张姓同学和陈姓同学选择了刘老师数据库课程且各门课程平均成绩大于60的学生的课程成绩为NULL更新为0。

(7)显示男同学的学号、姓名、班级、课程名称和课程成绩,要求按选择的课程门数和班级进行排序。

 

(8)现在有一门必修课,课程编码为‘0001’,在SC中加入相关信息(其成绩为NULL)后老师只有录入相关成绩就行了。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1