哈工大 数据库系统与设计 第2章练习
数据库设计练习5篇

数据库设计练习5篇第一篇:数据库设计练习数据库设计练习1.根据周围的实际情况,选择一个小型的数据库应用项目,例如仓库管理系统、物流管理系统、图书馆管理系统等。
2.进行系统需求分析,写出系统需求分析报告,应包括采用的设计方法、数据流图和数据字典。
3.进行系统的概念设计,使用E-R图表示对数据库中要存储的信息及语义进行详细描述,对数据约束和数据之间的关联进行详细描述。
4.进行系统的逻辑设计,详细描述系统需要的基本表及属性、视图和索引,对基本表的主、外键等进行说明,对基本表中数据的约束条件进行说明。
5.在SQL Server 2005中,实现系统中所需基本表、视图、存储过程、完整性等要求的定义。
6.在建立的数据库中,插入相应示例数据,并写出实现相应功能的SQL语句。
第二篇:数据库综合练习教学设计数据库综合练习教学设计1、认知要求:熟练掌握数据库建立熟练掌握数据的查询理解数据收集处理的过程2、操作要求:使用ACCESSXX完成一次数据调查处理的全过程3、情感要求:参与调查积极主动培养团队协作精神树立合理使用电脑的观念1、引入:大家有没有遇到过街头调查?今天我们在机房里也作一次调查而且用我们所学的ACCESS数据库管理系统来处理调查数据2、学生分组调查数据的收集由教师规定每组的调查内容每组学生进行分工ACCESS操作员:建立调查表结构,记录的输入调查者:根据调查内容访问班中其他同学被调查者:接受调查者的调查老师:适时引导,及时调控数据的查询学生:根据调查内容,选择恰当的查询要求,进行查询老师:适时讲解、合理引导调查结论由组长汇报调查结论3、简要小结小结数据收集处理的过程对调查活动作评点4、作业根据本次调查内容,对其他班的同学进行调查,得出结论。
第三篇:数据库设计用户信息表allUsersuserInfoId int 用户idusername varcher(15)用户名nicename varchar(15)昵称password varchar(15)密码nationalId int民族age int 年龄sex int 性别degreeId int 学历height int 身高cityId int 籍贯userWork int 工作areaCountyId int 所在区县salary int 工资marriageId int 婚姻houseId int 住房信息headimage 相片hobby varchar(20)爱好(null)introduceYourself char(200)介绍自己 integralint积分默认值0择友要求表 allFriendRequirefriendRequireId int 择友要求id userInfoId int 用户idfriendAge_one int 年龄1friendAge_two int 年龄2friendHeight_one int 身高1friendHeight_two int 身高2friendMarriageId int 婚姻friendDegreeId int 学历friendAreaCountyId int 所在区县 friendhouseId int 住房信息住房信息表 allHousehouseId int 住房idhouse varchar(10)住房情况礼物表allGiftgiftid int 礼物idgiftpicturesId int 礼物图片giftNumber int 礼物数量userInfoId int 用户id礼物图片表allGiftPicturesgiftNumberId int 礼物图片idgiftPictures image 礼物图片oneIntegralint 单个积分价值民族表allNationalnationalId int 民族Id(关联用户信息表)nationals varchar(5)民族学历表allDegreedegreeId int 学历id(关联用户信息表)degree varchar(10)学历籍贯表allNativenativeId int 省native varchar(10)省cityId int 市城市表allCitycityId int 城市Idcity varchar(10)城市天津市区县表allAreaCounty areaCountyId int 区县id areaCounty varchar(10)区县婚姻状态表allMarriagemarriageId int 婚姻状态Idmarriage varchar(10)婚姻状态相册表allHeadsheadsId int 相片Idheads image(null)相片userInfoid 用户Id爱好表allHobbyhobbyId int 爱好idhobby varchar(10)爱好信息表(收发信件)allInformation informationId int 信息id InformationTitle varchar(50)信件标题Information varchar(200)信息内容outId int 是否已读fromInformationUserinfoId int 发信人idtoInformationUserinfoId int 收信人Id文章表allTitlearticleId int 文章iduserInfoId int 用户idtitle varchar(100)标题content text 文章内容最近查看allLookuplookmeUserInfoidone int 我看的用户id(依次来5个)mylookUserInfoidone int 看我的用户id(依次来5个)收藏表allCollectionuserInfoId int 用户idcollectionUserInfoId int 收藏的用户Id第四篇:数据库设计东北大学东软信息学院数据库原理与应用实验报告姓名:班级:学号: [实验名称]:数据库设计 [实验日期]: [实验目的]: [实验要求]:业务需求:银行有多个支行。
(完整版)哈尔滨工业大学数据库试题(含答案)

(完整版)哈尔滨工业大学数据库试题(含答案)试卷一(哈尔滨工业大学)一、选择题(每题1分,共20分)1.在数据管理技术的发展过程中,数据独立性最高的是()阶段。
A. 数据库系统B. 文件系统C. 人工管理D. 数据项管理2. ()是存储在计算机内的有结构的数据集合。
A. 网络系统B. 数据库系统C. 操作系统D. 数据库3. 在数据库的三级模式结构中,描述数据库中全体数据的全局逻辑结构和特征的是()。
A. 外模式B. 内模式C. 存储模式D. 模式4. 作为关系数据系统,最小应具备的关系运算是()。
A. 排序、索引、统计B. 选择、投影、连接C. 关联、更新、排序D. 显示、打印、制表5. 在select语句中使用group by Sno时,Sno 必须出现在()子句中。
A. whereB. fromC. selectD. having6. 在where语句的条件表达式中,与零个或多个字符匹配的通配符是()。
A. *B. ?C. %D. _7. 对关系模式进行分解时,要求保持函数依赖,最高可以达到()。
A. 2NFB. 3NFC. BCNFD. 4NF8. 在关系模式R(U,F)中,Y∈XF+是X→Y是否成立的()。
A. 充分必要条件B. 必要条件C. 充分条件D. 既不充分也不必要条件9. 在关系数据库设计阶段中,完成关系模式设计的阶段是()。
A. 需求分析阶段B. 概念设计阶段C. 逻辑设计阶段D. 物理设计阶段10. 基本E-R图就是数据库的()。
A. 外模式B. 逻辑模式C. 内模式D. 概念模式11. 从数据流图构造E-R图时,选择实体一般应先考虑数据流图中的()。
A. 数据项B. 数据流C. 数据处理D. 数据存储12. 以下()不是当前常用的存取方法。
A. 索引方法B. 聚簇方法C. HASH方法D. 链表方法13. 事务一旦提交,对数据库的改变是永久的,这是事务的()。
A. 原子性B. 一致性C. 隔离性D. 持久性14. 并发控制要解决的根本问题是保持数据库状态的()。
数据库系统(下):管理与技术_哈尔滨工业大学中国大学mooc课后章节答案期末考试题库2023年

数据库系统(下):管理与技术_哈尔滨工业大学中国大学mooc课后章节答案期末考试题库2023年1.DBMS管理数据库缓冲区有四种策略:No Steal, Steal, No Force, Force。
则效率较低但不会出现问题的策略组合是_________,而效率最高最常用但会出现问题的策略组合是_________。
参考答案:No Steal+ Force,Steal + No Force;2.下列说法正确的是___________。
参考答案:两阶段封锁法是可串行化的并行调度算法;3.T1,T2是两个事务,图(a)(b)给出这两个事务的两种调度S1,S2,关于S1,S2,说法正确的选项是_____________。
【图片】参考答案:S1是不可串行化调度,S2是可串行化调度;4.若事务T对数据M已加S锁,在不改变S锁的情况下,则其它事务对数据M__________。
参考答案:可以读,但不可以写;5.关于稀疏索引和稠密索引,下列说法正确的是_______。
参考答案:如果一个搜索码的值在稠密索引中不存在,则在主文件中对应该搜索码值的记录也不存在6.关于给出的九个关系代数操作:【图片】问任何时候都能够用一趟算法实现的操作的个数是_______。
参考答案:17.主索引通常确定“表”数据的__________。
参考答案:物理顺序8.有效性确认是一种并发控制方法。
如下图(a)(b)中T和U是两个事务,X和Y是数据对象。
T要进行有效性确认,下列说法正确的是__________。
【图片】参考答案:图(a)事务T的有效性可以确认;图(b)事务T的有效性不可以确认;9.关于基于散列的两趟算法,下列说法正确的是_______。
参考答案:第一趟散列的目的是使数据子集具有某一种特性(如具有相同的散列值),而第二趟散列的目的是提高数据处理的速度。
10.关于逻辑查询优化和物理查询优化,下列说法正确的是________。
参考答案:逻辑查询优化是关系代数操作次序的优化;物理查询优化是关系代数操作实现算法选择的优化11.关于B+树,下列说法不正确的是_________。
数据库第二章课后习题解答

第3部分习题及其解答第一章的两道题3-2 习题22.6 分别把习题1.10、习题1.11的ER图转换成关系模型数据结构。
【参考答案】1.习题1.10的ER图可转换成如下的关系模型数据结构。
①程序员(编号,姓名,性别,年龄,单位,职称),其中编号是关键字;②程序(程序名称,版权,专利号,价格),其中程序名称是关键字;③设计(编号,程序名称,开始时间,结束时间),其中(编号,程序名称)是关键字。
2.习题1.11的ER图可转换成如下的关系模型数据结构。
①工厂(工厂名称,厂址,联系电话),其中工厂名称是关键字;②产品(产品号,产品名,规格,单价),其中产品号是关键字;③工人(工人编号,姓名,性别,职称,工厂名称,雇用期,月薪),其中工人编号是关键字,工厂名称是外关键字,雇用期和月薪是联系属性;④生产(工厂名称,产品号,月产量),其中(工厂名称,产品号)是关键字,生产关系是表示联系的。
2.8 判断下列情况,分别指出它们具体遵循那一类完整性约束规则?1.用户写一条语句明确指定月份数据在1~12之间有效。
2.关系数据库中不允许主键值为空的元组存在。
3.从A关系的外键出发去找B关系中的记录,必须能找到。
【解答】1.用户用语句指定月份数据在1~12之间有效,遵循用户定义的完整性约束规则。
2.关系数据库中不允许主键值为空的元组存在,遵循实体完整性约束规则;3.从A关系的外键出发去找B关系的记录,必须能找到,遵循引用完整性约束规则。
2.9 判断下列情况,分别指出他们是用DML还是用DDL来完成下列操作?1.创建“学生”表结构。
2.对“学生”表中的学号属性,其数据类型由“整型”修改为“字符型”。
3.把“学生”表中学号“021”修改为“025”。
【解答】1.创建“学生”表结构,即定义一个关系模式,用DDL 完成。
2.修改“学生”表中学号属性的数据类型,即修改关系模式的定义,用DDL 完成。
3.修改“学生”表中学号属性的数据值,即对表中的数据进行操作,用DML 完成。
数据库系统原理第二章的习题.doc

第2章关系数据库一、选择题1、关于关系模型,下列叙述不正确的是()。
A. 一个关系至少要有一个候选码B. 列的次序可以任意交换C. 行的次序可以任意交换D. 一个列的值可以来自不同的域2、下列说法正确的是()。
A. 候选码都可以唯一地标识一个元组B. 候选码中只能包含一个属性C. 主属性可以取空值D. 关系的外码不可以取空值3、关系操作中,操作的对象和结果都是()。
A. 记录B. 集合C. 元组D. 列4、假设存在一张职工表,包含“性别”属性,要求这个属性的值只能取“男”或“女”,这属于()。
A. 实体完整性B. 参照完整性C. 用户定义的完整性D. 关系不变性5、有两个关系R(A, B, C)和S(B, C, D),将R和S进行自然连接,得到的结果包含几个列()A. 6B. 4C. 5D. 2二、判断题1、关系模型的一个特点是,实体以及实体之间的联系都可以使用相同的结构类型来表示。
()2、关系模型中,非主属性不可能出现在任何候选码中。
()3、关系模式是对关系的描述,关系是关系模式在某一时刻的状态或内容。
()三、填空题1、在关系模型中,关系操作包括查询、____________、____________和_____________等。
2、关系模型的三类完整性约束是指______________、_______________和_____________。
3、关系模型包括8种查询操作,其中__________、_________、并、________和笛卡儿积是5种基本操作,其他操作可以用基本操作定义和导出。
4、职工(职工号,姓名,年龄,部门号)和部门(部门号,部门名称)存在引用关系,其中________________是参照关系,____________是外码。
四、综合题假设有一个数据库包含以下关系模式:Teacher(Tno, Tname, Tage, Tsex)Department(Dno, Dname, Tno)Work(Tno, Dno,Year, Salary)教师表Teacher由教师代码Tno、教师名字Tname、教师年龄Tage、教师性别Tsex组成。
数据库系统基础教程第二章答案解析

Exercise 2.2.1aFor relation Accounts, the attributes are:acctNo, type, balanceFor relation Customers, the attributes are:firstName, lastName, idNo, accountExercise 2.2.1bFor relation Accounts, the tuples are:(12345, savings, 12000),(23456, checking, 1000),(34567, savings, 25)For relation Customers, the tuples are:(Robbie, Banks, 901-222, 12345),(Lena, Hand, 805-333, 12345),(Lena, Hand, 805-333, 23456)Exercise 2.2.1cFor relation Accounts and the first tuple, the components are: 123456 → acctNosavings → type12000 → balanceFor relation Customers and the first tuple, the components are: Robbie → firstNameBanks → lastName901-222 → idNo12345 → accountExercise 2.2.1dFor relation Accounts, a relation schema is:Accounts(acctNo, type, balance)For relation Customers, a relation schema is:Customers(firstName, lastName, idNo, account) Exercise 2.2.1eAn example database schema is:Accounts (acctNo,type,balance)Customers (firstName,lastName,idNo,account)Exercise 2.2.1fA suitable domain for each attribute:acctNo → Integertype → Stringbalance → IntegerfirstName → StringlastName → StringidNo → String (because there is a hyphen we cannot use Integer)account → IntegerExercise 2.2.1gAnother equivalent way to present the Account relation:Another equivalent way to present the Customers relation:Exercise 2.2.2Examples of attributes that are created for primarily serving as keys in a relation:Universal Product Code (UPC) used widely in United States and Canada to track products in stores.Serial Numbers on a wide variety of products to allow the manufacturer to individually track each product.Vehicle Identification Numbers (VIN), a unique serial number used by the automotive industry to identify vehicles.Exercise 2.2.3aWe can order the three tuples in any of 3! = 6 ways. Also, the columns can be ordered in any of 3! = 6 ways. Thus, the number of presentations is 6*6 = 36. Exercise 2.2.3bWe can order the three tuples in any of 5! = 120 ways. Also, the columns can be ordered in any of 4! = 24 ways. Thus, the number of presentations is120*24 = 2880Exercise 2.2.3cWe can order the three tuples in any of m! ways. Also, the columns can be ordered in any of n! ways. Thus, the number of presentations is n!m!Exercise 2.3.1aCREATE TABLE Product (maker CHAR(30),model CHAR(10) PRIMARY KEY,type CHAR(15));Exercise 2.3.1bCREATE TABLE PC (model CHAR(30),speed DECIMAL(4,2),ram INTEGER,hd INTEGER,price DECIMAL(7,2));Exercise 2.3.1cCREATE TABLE Laptop (model CHAR(30),speed DECIMAL(4,2),ram INTEGER,hd INTEGER,screen DECIMAL(3,1),price DECIMAL(7,2));Exercise 2.3.1dCREATE TABLE Printer (model CHAR(30),color BOOLEAN,type CHAR (10),price DECIMAL(7,2));Exercise 2.3.1eALTER TABLE Printer DROP color;Exercise 2.3.1fALTER TABLE Laptop ADD od CHAR (10) DEFAULT ‘none’; Exercise 2.3.2aCREATE TABLE Classes (class CHAR(20),type CHAR(5),country CHAR(20),numGuns INTEGER,bore DECIMAL(3,1),displacement INTEGER);Exercise 2.3.2bCREATE TABLE Ships (name CHAR(30),class CHAR(20),launched INTEGER);Exercise 2.3.2cCREATE TABLE Battles (name CHAR(30),date DATE);Exercise 2.3.2dCREATE TABLE Outcomes (ship CHAR(30),battle CHAR(30),result CHAR(10));Exercise 2.3.2eALTER TABLE Classes DROP bore;Exercise 2.3.2fALTER TABLE Ships ADD yard CHAR(30);Exercise 2.4.1aR1 := σspeed ≥ 3.00 (PC)R2 := πmodel(R1)model100510061013Exercise 2.4.1bR1 := σhd ≥ 100 (Laptop)R2 := Product (R1)R3 := πmaker (R2)makerEABFGExercise 2.4.1cR1 := σmaker=B (Product PC)R2 := σmaker=B (Product Laptop)R3 := σmaker=B (Product Printer)R4 := πmodel,price (R1)R5 := πmodel,price (R2)R6: = πmodel,price (R3)R7 := R4 R5 R6model price1004 6491005 6301006 10492007 1429Exercise 2.4.1dR1 := σcolor = true AND type = laser (Printer)R2 := πmodel (R1)model30033007Exercise 2.4.1eR1 := σtype=laptop (Product)R2 := σtype=PC(Product)R3 := πmaker(R1)R4 := πmaker(R2)R5 := R3 – R4makerFGExercise 2.4.1fR1 := ρPC1(PC)R2 := ρPC2(PC)R3 := R1 (PC1.hd = PC2.hd AND PC1.model <> PC2.model) R2R4 := πhd(R3)hd25080160Exercise 2.4.1gR1 := ρPC1(PC)R2 := ρPC2(PC)R3 := R1 (PC1.speed = PC2.speed AND PC1.ram = PC2.ram AND PC1.model < PC2.model) R2R4 := πPC1.model,PC2.model(R3)PC1.model PC2.model1004 1012Exercise 2.4.1hR1 := πmodel(σspeed ≥ 2.80(PC)) πmodel(σspeed ≥ 2.80(Laptop))R2 := πmaker,model(R1 Product)R3 := ρR3(maker2,model2)(R2)R4 := R2 (maker = maker2 AND model <> model2) R3R5 := πmaker(R4)makerBEExercise 2.4.1iR1 := πmodel,speed(PC)R2 := πmodel,speed(Laptop)R3 := R1 R2R4 := ρR4(model2,speed2)(R3)R5 := πmodel,speed (R3 (speed < speed2 ) R4)R6 := R3 – R5R7 := πmaker(R6 Product)makerBExercise 2.4.1jR1 := πmaker,speed(Product PC)R2 := ρR2(maker2,speed2)(R1)R3 := ρR3(maker3,speed3)(R1)R4 := R1 (maker = maker2 AND speed <> speed2) R2R5 := R4 (maker3 = maker AND speed3 <> speed2 AND speed3 <> speed) R3R6 := πmaker(R5)makerADEExercise 2.4.1kR1 := πmaker,model(Product PC)R2 := ρR2(maker2,model2)(R1)R3 := ρR3(maker3,model3)(R1)R4 := ρR4(maker4,model4)(R1)R5 := R1 (maker = maker2 AND model <> model2) R2R6 := R3 (maker3 = maker AND model3 <> model2 AND model3 <> model) R5R7 := R4 (maker4 = maker AND (model4=model OR model4=model2 OR model4=model3)) R6R8 := πmaker(R7)makerABDEExercise 2.4.2aπmodelσspeed≥3.00PCExercise 2.4.2bLaptopσhd ≥ 100 ProductmakerExercise 2.4.2cσmaker=B πmodel,price σmaker=B πmodel,price σmaker=B πmodel,priceProduct PC Laptop Printer ProductProductExercise 2.4.2d Printerσcolor = true AND type = laserπmodelExercise 2.4.2eσtype=laptopσtype=PC πmakerπmaker ProductProductExercise 2.4.2fρPC1ρPC2 (PC1.hd = PC2.hd AND PC1.model <> PC2.model)πhdPC PCExercise 2.4.2gρPC1ρPC2PC PC(PC1.speed = PC2.speed AND PC1.ram = PC2.ram AND PC1.model < PC2.model)πPC1.model,PC2.modelExercise 2.4.2hPC Laptop σspeed ≥ 2.80σspeed ≥ 2.80πmodelπmodel πmaker,modelρR3(maker2,model2)(maker = maker2 AND model <> model2)makerExercise 2.4.2iPCLaptopProductπmodel,speed πmodel,speed ρR4(model2,speed2)πmodel,speed(speed < speed2 )–makerExercise 2.4.2jProduct PC πmaker,speed ρR3(maker3,speed3)ρR2(maker2,speed2)(maker = maker2 AND speed <> speed2)(maker3 = maker AND speed3 <> speed2 AND speed3 <> speed)makerExercise 2.4.2kπmaker(maker4 = maker AND (model4=model OR model4=model2 OR model4=model3)) (maker3 = maker AND model3 <> model2 AND model3 <> model)(maker = maker2 AND model <> model2)ρR2(maker2,model2)ρR3(maker3,model3)ρR4(maker4,model4)πmaker,modelProduct PCExercise 2.4.3aR1 := σbore ≥ 16 (Classes)R2 := πclass,country (R1)Exercise 2.4.3bR1 := σlaunched < 1921 (Ships)R2 := πname (R1)RamilliesRenownRepulseResolutionRevengeRoyal OakRoyal SovereignTennesseeExercise 2.4.3cR1 := σbattle=Denmark Strait AND result=sunk(Outcomes)R2 := πship (R1)shipBismarckHoodExercise 2.4.3dR1 := Classes ShipsR2 := σlaunched > 1921 AND displacement > 35000 (R1)R3 := πname (R2)nameIowaMissouriMusashiNew JerseyNorth CarolinaWashingtonWisconsinYamatoExercise 2.4.3eR1 := σbattle=Guadalcanal(Outcomes)R2 := Ships (ship=name) R1R3 := Classes R2R4 := πname,displacement,numGuns(R3)name displacement numGuns Kirishima 32000 8Washington 37000 9Exercise 2.4.3fR1 := πname(Ships)R2 := πship(Outcomes)R3 := ρR3(name)(R2)R4 := R1 R3nameCaliforniaHarunaHieiIowaKirishimaKongoMissouriMusashiNew JerseyNorth CarolinaRamilliesRenownRepulseResolutionRevengeRoyal OakRoyal SovereignTennesseeWashingtonExercise 2.4.3gFrom 2.3.2, assuming that every class has one ship named after the class.R1 := πclass (Classes) R2 := πclass (σname <> class (Ships)) R3 := R1 – R2Exercise 2.4.3hR1 := πcountry (σtype=bb (Classes))R2 := πcountry (σtype=bc (Classes))R3 := R1 ∩ R2Exercise 2.4.3iR1 := πship,result,date (Battles (battle=name) Outcomes)R2 := ρR2(ship2,result2,date2)(R1)R3 := R1 (ship=ship2 AND result=damaged AND date < date2) R2R4 := πship (R3)No results from sample data.Exercise 2.4.4aσbore ≥ 16πclass,countryClassesExercise 2.4.4bσlaunched < 1921πnameShipsExercise 2.4.4cWisconsin Yamato Arizona Bismarck Duke of York Fuso Hood King George V Prince of Wales Rodney Scharnhorst South Dakota West Virginia Yamashiro class Bismarck countryJapan Gt. BritainOutcomesπshipσbattle=Denmark Strait AND result=sunkExercise 2.4.4dClasses Ships σlaunched > 1921 AND displacement > 35000πnameExercise 2.4.4e σbattle=Guadalcanal Outcomes ShipsClasses(ship=name)πname,displacement,numGunsExercise 2.4.4fShipsOutcomesπnameπship ρR3(name)Exercise 2.4.4g ClassesShips πclass σname <> class πclass –Exercise 2.4.4hClasses Classesσtype=bb σtype=bcπcountry πcountry∩Exercise 2.4.4iπship(ship=ship2 AND result=damaged AND date < date2)ρR2(ship2,result2,date2)πship,result,date(battle=name)Battles OutcomesExercise 2.4.5The result of the natural join has only one attribute from each pair of equated attributes. On the other hand, the result of the theta-join has both columns of the attributes and their values are identical.Exercise 2.4.6UnionIf we add a tuple to the arguments of the union operator, we will get all of the tuples of the original result and maybe the added tuple. If theadded tuple is a duplicate tuple, then the set behavior will eliminate that tuple. Thus the union operator is monotone.IntersectionIf we add a tuple to the arguments of the intersection operator, we will get all of the tuples of the original result and maybe the added tuple. If the added tuple does not exist in the relation that it is added but does exist in the other relation, then the result set will include the added tuple.Thus the intersection operator is monotone.DifferenceIf we add a tuple to the arguments of the difference operator, we may not get all of the tuples of the original result. Suppose we have relations R and S and we are computing R – S. Suppose also that tuple t is in R but not in S. The result of R – S would include tuple t. However, if we add tuple t to S, then the new result will not have tuple t. Thus the difference operator is not monotone.ProjectionIf we add a tuple to the arguments of the projection operator, we will get all of the tuples of the original result and the projection of the added tuple. The projection operator only selects columns from the relation and does not affect the rows that are selected. Thus the projection operator is monotone.SelectionIf we add a tuple to the arguments of the selection operator, we will get all of the tuples of the original result and maybe the added tuple. If the added tuple satisfies the select condition, then it will be added to the new result. The original tuples are included in the new result because they still satisfy the select condition. Thus the selection operator is monotone.Cartesian ProductIf we add a tuple to the arguments of the Cartesian product operator, we will get all of the tuples of the original result and possibly additional tuples. The Cartesian product pairs the tuples of one relation with the tuples of another relation. Suppose that we are calculating R x S where R has m tuples and S has n tuples. If we add a tuple to R that is not already in R, then we expect the result of R x S to have (m + 1) * n tuples.Thus the Cartesian product operator is monotone.Natural JoinsIf we add a tuple to the arguments of a natural join operator, we will get all of the tuples of the original result and possibly additional tuples.The new tuple can only create additional successful joins, not less. If, however, the added tuple cannot successfully join with any of theexisting tuples, then we will have zero additional successful joins. Thus the natural join operator is monotone.Theta JoinsIf we add a tuple to the arguments of a theta join operator, we will get all of the tuples of the original result and possibly additional tuples. The theta join can be modeled by a Cartesian product followed by a selection on some condition. The new tuple can only create additional tuples in the result, not less. If, however, the added tuple does not satisfy the select condition, then no additional tuples will be added to the result. Thus the theta join operator is monotone.RenamingIf we add a tuple to the arguments of a renaming operator, we will get all of the tuples of the original result and the added tuple. The renaming operator does not have any effect on whether a tuple is selected or not. In fact, the renaming operator will always return as many tuples as its argument. Thus the renaming operator is monotone.Exercise 2.4.7aIf all the tuples of R and S are different, then the union has n + m tuples, and this number is the maximum possible.The minimum number of tuples that can appear in the result occurs if every tuple of one relation also appears in the other. Then the union has max(m , n) tuples.Exercise 2.4.7bIf all the tuples in one relation can pair successfully with all the tuples in the other relation, then the natural join has n * m tuples. This number would be the maximum possible.The minimum number of tuples that can appear in the result occurs if none of the tuples of one relation can pair successfully with all the tuples in the other relation. Then the natural join has zero tuples.Exercise 2.4.7cIf the condition C brings back all the tuples of R, then the cross product will contain n * m tuples. This number would be the maximum possible.The minimum number of tuples that can appear in the result occurs if the condition C brings back none of the tuples of R. Then the cross product has zero tuples.Exercise 2.4.7dAssuming that the list of attributes L makes the resulting relation πL(R) and relation S schema compatible, then the maximum possible tuples is n. This happens when all of the tuples of πL(R) are not in S.The minimum number of tuples that can appear in the result occurs when all of the tuples in πL(R) appear in S. Then the difference has max(n–m , 0) tuples.Exercise 2.4.8Defining r as the schema of R and s as the schema of S:1.πr(R S)2.R δ(πr∩s(S)) where δ is the duplicate-elimination operator in Section 5.2 pg. 2133.R – (R –πr(R S))Exercise 2.4.9Defining r as the schema of R1.R - πr(R S)Exercise 2.4.10πA1,A2…An(R S)Exercise 2.5.1aσspeed < 2.00 AND price > 500(PC) = øModel 1011 violates this constraint.Exercise 2.5.1bσscreen < 15.4 AND hd < 100 AND price ≥ 1000(Laptop) = øModel 2004 violates the constraint.Exercise 2.5.1cπmaker(σtype = laptop(Product)) ∩ πmaker(σtype = pc(Product)) = øManufacturers A,B,E violate the constraint.Exercise 2.5.1dThis complex expression is best seen as a sequence of steps in which we define temporary relations R1 through R4 that stand for nodes of expression trees. Here is the sequence:R1(maker, model, speed) := πmaker,model,speed(Product PC)R2(maker, speed) := πmaker,speed(Product Laptop)R3(model) := πmodel(R1 R1.maker = R2.maker AND R1.speed ≤ R2.speed R2)R4(model) := πmodel(PC)The constraint is R4 ⊆ R3Manufacturers B,C,D violate the constraint.Exercise 2.5.1eπmodel(σLaptop.ram > PC.ram AND Laptop.price ≤ PC.price(PC × Laptop)) = øModels 2002,2006,2008 violate the constraint.Exercise 2.5.2aπclass(σbore > 16(Classes)) = øThe Yamato class violates the constraint.Exercise 2.5.2bπclass(σnumGuns > 9 AND bore > 14(Classes)) = øNo violations to the constraint.Exercise 2.5.2cThis complex expression is best seen as a sequence of steps in which we define temporary relations R1 through R5 that stand for nodes of expression trees. Here is the sequence:R1(class,name) := πclass,name(Classes Ships)R2(class2,name2) := ρR2(class2,name2)(R1)R3(class3,name3) := ρR3(class3,name3)(R1)R4(class,name,class2,name2) := R1 (class = class2 AND name <> name2) R2R5(class,name,class2,name2,class3,name3) := R4 (class=class3 AND name <> name3 AND name2 <> name3) R3The constraint is R5 = øThe Kongo, Iowa and Revenge classes violate the constraint.Exercise 2.5.2dπcountry(σtype = bb(Classes)) ∩ πcountry(σtype = bc(Classes)) = øJapan and Gt. Britain violate the constraint.Exercise 2.5.2eThis complex expression is best seen as a sequence of steps in which we define temporary relations R1 through R5 that stand for nodes of expression trees. Here is the sequence:R1(ship,bat tle,result,class) := πship,battle,result,class(Outcomes (ship = name) Ships)R2(ship,battle,result,numGuns) := πship,battle,result,numGuns(R1 Classes)R3(ship,battle) := πship,battle(σnumGuns < 9 AND result = sunk (R2))R4(ship2,battle2) := ρR4(ship2,battle2)(πship,battle(σnumGuns > 9(R2)))R5(ship2) := πship2(R3 (battle = battle2) R4)The constraint is R5 = øNo violations to the constraint. Since there are some ships in the Outcomes table that are not in the Ships table, we are unable to determine the number of guns on that ship.Exercise 2.5.3Defining r as the schema A1,A2,…,A n and s as the schema B1,B2,…,B n:πr(R) πs(S) = øwhere is the antisemijoinExercise 2.5.4The form of a constraint as E1 = E2 can be expressed as the other two constraints.Using the “equating an expression to the empty set” method, we can simply say:E1– E2 = øAs a containment, we can simply say:E1⊆ E2 AND E2⊆ E1Thus, the form E1 = E2 of a constraint cannot express more than the two other forms discussed in this section.。
数据库基础及其应用第二章课后作业

第二章关系运算1.关系数据模型包括(关系数据结构)、(关系完整性规则)和(关系运算)三个方面。
2.在一个关系中,不同的列可以对应同一个(域),但必须具有不同的(列名)。
3.顾客购物的订单和订单明细之间是(1)对(多)的联系。
4.主码是一种(候选)码,主码中的(属性)个数没有限制。
5.若一个关系为R(学生号,姓名,性别,年龄),则(学生号)可以作为该关系的主码,姓名、性别和年龄为该关系的(非主)属性。
6.关系完整性包括(实体)完整性、(参照)完整性和(用户定义)的完整性三个方面。
7.在参照和被参照的关系中,每个外码值或者为(空值),或者等于某个(主码)值。
8.传统的集合运算包括(并)、(交)、(差)和(笛卡尔积)四种。
9.设一个关系A具有a1个属性和a2个元组,关系B具有b1个属性和b2个元组,则关系AxB具有(a1+b1)个属性和(a2xb2)个元组。
10.设一个关系模式为R(A,B,C),对应的关系内容为R={{1,10,50}, {2,10,60}, {3,20,72}, {4,30,60}},则δB>15(R)属于(选择)运算,运算结果中包含有(2)个元组。
11.设一个关系模式为R(A,B,C),对应的关系内容为R={{1,10,50}, {2,10,60}, {3,20,72}, {4,30,60}},则的运算结果中包含有(4)个元组,每个元组包含有(3)个分量。
12.设一个学生关系为S(学生号,姓名),课程关系为C(课程号,课程名),选课关系为X(学生号,课程号,成绩),则选修了课程名为’程序设计’课程的全部学生信息所对应的运算(C))))。
表达式为(Π学生号(X(δ课程名=’程序设计’13.设一个学生关系为S(学生号,姓名),课程关系为C(课程号,课程名),选课关系为X(学(X))生号,课程号,成绩),则求出所有选修课程信息的运算表达式为(Π课程号与(C)的自然连接。
14.设D1、D2、和D3域的基数分别为2、3、4,则D1*D2*D3的元组数为(24),每个元组有(3)个分量。
计算机二级(VF)数据库设计基础章节练习试卷2(题后含答案及解析)

计算机二级(VF)数据库设计基础章节练习试卷2(题后含答案及解析)题型有:1. 选择题选择题(每小题2分,共70分)下列各题A、B、C、D四个选项中,只有一个选项是正确的,请将正确选项涂写在答题卡相应位置上。
1.下列数据模型中,具有坚实理论基础的是______。
A.层次模型B.网状模型C.关系模型D.以上)个都是正确答案:C 涉及知识点:数据库设计基础2.下列关于数据库系统,说法正确的是______。
A.数据库中只存在数据项之间的联系B.数据库中只存在记录之间的联系C.数据库中数据项之间和记录之间都存在联系D.数据库中数据项之间和记录之间都不存在联系正确答案:C 涉及知识点:数据库设计基础3.从关系模式中指定若干个属性组成新的关系的运算称为______。
A.连接B.投影C.选择D.排序正确答案:B 涉及知识点:数据库设计基础4.数据处理的最小单位是______。
A.数据B.数据元素C.数据项D.数据结构正确答案:C 涉及知识点:数据库设计基础5.索引属于______。
A.模式B.内模式C.外模式D.概念模式正确答案:B 涉及知识点:数据库设计基础6.下述关于数据库系统的叙述中正确的是______。
A.数据库系统减少了数据冗余B.数据库系统避免了一切冗余C.数据库系统中数据的一致性是指数据类型一致D.数据库系统比文件系统能管理更多的数据正确答案:A 涉及知识点:数据库设计基础7.数据库系统的核心是______。
A.数据库B.数据库管理系统C.模拟模型D.软件工程正确答案:B 涉及知识点:数据库设计基础8.为了合理组织数据,应遵循的设计原则是______。
A.“一事一地”的原则,即一个表描述一个实体或实体之间的一种联系B.用外部关键字保证有关联的表之间的联系C.表中的字段必须是原始数据和基本数据元素,并避免在表之间出现重复字段D.以上各原则都包括正确答案:D 涉及知识点:数据库设计基础9.关系运算中花费时间可能最长的运算是______。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
7.关系的名称和它的( 属性名 )称为关系的模式。
8.在关系代数的表达式中,符号Π 表示的运算是(投影 )。
9.在关系代数的表达式中,符号σ 表示的运算是( 选择 )。 10.经过选择运算后,所得关系的属性数(等于)原关系的属性 数。 11.经过投影运算后,所得关系的元组数(小于或等于 )原关 系元组的属性数。 12.关系模型由( 关系数据结构 )、( 关系操作集合 )和关系完 整性约束三部分组成。 13.关系模型允许定义三类完整性约束:( 实体完整性 ( 参照完整性 )和( 用户定义完整性 )。 )、
2. 当前数据库系统的主流是(关系数据库系统
)。
3.一个实体的主码属性不能为空,称为( 实体完整性 )。 4.一个实体的某个属性(集)值只能引用另一个实体确实存 在的码的属性(集),称为( 参照完整性 )。 5.实体的完整性是指在建立数据库时,( 主码 )不能为空。 属性 )。
6.关系的标题栏中的名字称为(
B.元组个数小于投影前的元组个数
C.元组个数小于或等于投影前的元组个数 D.元组个数大于或等于投影前的元组个数 4. 在关 系 中, 能 唯一标识元组的属性集称为关系模式的 ________。 A.候选码 B.主码 C.外码 D.主键
5.关系R与关系S只有一个公共属性,T1是R与S作θ 连接的结 果,T2是R与S自然连接的结果,则__________。 (A)T1的属性个数等于T2的属性个数 (B)T1的属性个数小于T2的属性个数 (C)T1的属性个数大于或等于T2的属性个数 (D)T1的属性个数大于T2的属性个数
7. 基本关系中,行的次序不可以交换。(
8. 基本关系中,列的次序不可以交换。(态的,随时间不断变化的。(
10.数据库管理系统为了实现数据库的完整性,通常提供授权 功能。( ) 11.对于关系数据库系统,用户即要提出“做什么”,也要指 出“怎么做”。( )
四、简答题:
6.学生关系模式为R1(学号,姓名,性别,班号,……), 其 中 学 号 为 主 码 , 班 级 关 系 模 式 为 R2 ( 班 号 , 专 业 , 教 室,……),其中班号为主码;则学生关系模式中的外码应 该设为________。 A.学号 二、填空题: 1. 关系数据库系统是以( 关系 )为基础的数据库系统。 B.姓名 C.性别 D.班号
第二章 练习
一、选择题: 1.关系中标题栏中各列的名称称为________。 A.对象 B.元组 C.属性 D.记录
2.在下述关系的特点中,错误的是________。
A.列可以交换 C.任意两元组不能相同 B.行可以交换 D.表中的数据项可分
3.关系模式进行投影运算后__________。 A. 元组个数等于投影前的元组个数
三、判断题:
1.在R和S关系之间进行并、交、差运算,R和S的模式必须具 有:相同的属性集,属性的顺序相同。( )
2.码可以是一个或多个属性的集合。( )
3.参照完整性将保证数据库中实体之间相关数据的一致性。 ( ) 4. 基本关系中,不同的列不可出自同一个域。( 5. 基本关系中,任意两个元组可以完全相同。( 6. 基本关系中,每个分量是可以再分的数据项。( ) ) )
1. 基本概念:域、关系、元组、属性、主码、关系模式、关系 2. P80页4题 3. P80页5题(1)~(4) 4. P82页6题
5. 举例说明实体完整性规则
6. 举例说明参照完整性规则 7. 举例说明什么是外码