数据库基础教程课后习题答案顾韵华
数据库应用基础教程答案
数据库应用基础教程答案【篇一:access数据库应用基础教程(第三版)习题及答案】txt>程(第三版)习题集答案第1章数据库系统概述1. 什么是数据库?什么是数据库系统?答:数据库(database)是存放数据的仓库,严格的讲,数据库是长期存储在计算机内,有组织的,可共享的大量数据集合。
数据库系统(database systems),是由数据库及其管理软件组成的系统。
它是为适应数据处理的需要而发展起来的一种较为理想的数据处理的核心机构。
它是一个实际可运行的存储、维护和应用系统提供数据的软件系统,是存储介质、处理对象和管理系统的集合体。
2. 什么是数据库管理系统?它有哪些主要功能?答:数据库管理系统(database management system)是一种操纵和管理数据库的大型软件,用于建立、使用和维护数据库,简称dbms。
它对数据库进行统一的管理和控制,以保证数据库的安全性和完整性。
数据库管理系统的主要功能有:数据定义、数据操作、数据库的运行管理、数据组织、数据库的保护、数据库的维护和通信。
3. 说出几种常用的数据模型。
答:层次模型、网状模型、关系模型。
4. 什么是关系模型?答:关系模型是用二维表的形式表示实体和实体间联系的数据模型。
5. 简述数据库设计的步骤。
答:需求分析、概念结构设计、逻辑结构设计、物理结构设计、数据库的建立和测试、数据库运行和维护。
第2章 sql 语言简介1. 什么是sql语言?sql语言具有哪些特点和功能?答:sql是一种数据库查询和程序设计语言,用于存取数据以及查询更新和管理关系数据库系统。
sql的特点和功能有:查询,操作,定义和控制四个方面,sql语言具有高度的非过程化,语言简洁,语义明显,语法结构简单,直观易懂的特点。
sql语言即可以作为独立语言使用,用户可以在终端键盘上直接键入sql命令对数据库进行操作,也可以作为嵌入式语言,嵌入到其他高级语言中。
2. sql语言包含哪几个部分?答:sql语言包含4个部分:数据定义语言(ddl-data definition language)、数据查询语言(dql-data query language)、数据操纵语言(dml-data manipulation language)、数据控制语言(dcl-data control language)3. 在联接查询中,包含哪几类联接?答:联接可分为3类:(1)内部联接(典型的联接运算,使用类似于 = 或的比较运算符)。
(完整版)数据库课后习题及答案
第一章数据库系统概述选择题1实体-联系模型中,属性是指(C)A.客观存在的事物B.事物的具体描述C.事物的某一特征D.某一具体事件2对于现实世界中事物的特征,在E-R模型中使用(A)A属性描述B关键字描述C二维表格描述D实体描述3假设一个书店用这样一组属性描述图书(书号,书名,作者,出版社,出版日期),可以作为“键”的属性是(A)A书号B书名C作者D出版社4一名作家与他所出版过的书籍之间的联系类型是(B)A一对一B一对多C多对多D都不是5若无法确定哪个属性为某实体的键,则(A)A该实体没有键B必须增加一个属性作为该实体的键C取一个外关键字作为实体的键D该实体的所有属性构成键填空题1对于现实世界中事物的特征在E-R模型中使用属性进行描述2确定属性的两条基本原则是不可分和无关联3在描述实体集的所有属性中,可以唯一的标识每个实体的属性称为键4实体集之间联系的三种类型分别是1:1 、1:n 、和m:n5数据的完整性是指数据的正确性、有效性、相容性、和一致性简答题一、简述数据库的设计步骤答:1需求分析:对需要使用数据库系统来进行管理的现实世界中对象的业务流程、业务规则和所涉及的数据进行调查、分析和研究,充分理解现实世界中的实际问题和需求。
分析的策略:自下而上——静态需求、自上而下——动态需求2数据库概念设计:数据库概念设计是在需求分析的基础上,建立概念数据模型,用概念模型描述实际问题所涉及的数据及数据之间的联系。
3数据库逻辑设计:数据库逻辑设计是根据概念数据模型建立逻辑数据模型,逻辑数据模型是一种面向数据库系统的数据模型。
4数据库实现:依据关系模型,在数据库管理系统环境中建立数据库。
二、数据库的功能答:1提供数据定义语言,允许使用者建立新的数据库并建立数据的逻辑结构2提供数据查询语言3提供数据操纵语言4支持大量数据存储5控制并发访问三、数据库的特点答:1数据结构化。
2数据高度共享、低冗余度、易扩充3数据独立4数据由数据库管理系统统一管理和控制:(1)数据安全性(2)数据完整性(3)并发控制(4)数据库恢复第二章关系模型和关系数据库选择题1把E-R模型转换为关系模型时,A实体(“一”方)和B实体(“多”方)之间一对多联系在关系模型中是通过(A)来实现的A将A关系的关键字放入B关系中B建立新的关键字C建立新的联系D建立新的实体2关系S和关系R集合运算的结果中既包含S中元组也包含R中元组,但不包含重复元组,这种集合运算称为(A)A并运算B交运算C差运算D积运算3设有关系R1和R2,经过关系运算得到结果S,则S是一个(D)A字段B记录C数据库D关系4关系数据操作的基础是关系代数。
数据库系统基础教程课后答案第四章
4.2.7 In below figure there exists a many-to-one relationship between Babies and Births and another many-to-one relationship between Births and Mothers. From transitivity of relationships, there is a many-to-one relationship between Babies and Mothers. Hence a baby has a unique mother while a birth can allow more than one baby.
4.1.7
4.1.8 a)
(b)
4.1.9
Assumptions A Professor only works in at most one department. A course has at most one TA. A course is only taught by one professor and offered by one department. Students and professors have been assigned unique email ids. A course is uniquely identified by the course no, section no, and semester (e.g. cs157-3 spring 09).
4.2.4 The entity sets should have single attribute. a) Stars: starName b) Movies: movieName c) Studios: studioName. However there exists a many-to-many relationship between Studios and Contracts. Hence, in addition, we need more information about studios involved. If a contract always involves two studios, two attributes such as producingStudio and starStudio can replace the Studios entity set. If a contact can be associated with at most five studios, it may be possible to replace the Studios entity set by five attributes viz. studio1, studio2, studio3, studio4, and studio5. Alternately, a composite attribute containing concatenation of all studio names in a contact can be considered. A separator character such as "$" can be used. SQL allows searching of such an attribute using query like '%keyword%'
关于《数据库基础》课程教材建设的探讨
关 系 逻 辑 模 式 中各 关 系 模 式是 否存 在 异常, 怎样 的 设 计是 较 优 的 , 于 有 缺 陷的 对 逻辑 设 计 如 何 优 化 。 些 正 是 关 系 数 据 理 这 2 “ 论 、 践 、 理 论 实 践 ” 系 论 要 解决 的基 本 问 题 。“ 式 理 论 ” 分 将 理 实 再 再 体 范 部 结 构 简要 阐释 关 系 数据 理 论 , 函 数 依 赖 和 多 在 为 了体 现 理 论 与 实 践 并 重 的 特 点 , 本 值 依 赖 范 畴 内 讨 论 关 系 模 式 的规 范化 。 教材 的 编 写有 两 条主 线 , 以关 系数 据 库 即 对 于 一 个 实 际 问 题 , 用 数 据 库 开 发 运 理论 和 数 据 库 设 计 理 论 为 主 的 理 论 线 , 和 技 术 进行 基 于 数据 库 的 应 用 系统 的 设 计 与 以S QL语言 和 数据 库 应 用 系统 为 主 的 应用 开 发 , 一项 综 合性 的应 用 工 程 。 数 据 库 是 “ 线, 并且 两 条主 线 又相 互 渗 透 , 过 示 例融 应 用 开 发 方 法 与 技 术 ” 阐 述 数 据 库 应 用 通 将 三者有机结合。
重 点 突 出 基 础 性 和 应 用 性 。 构 建 基 于 数 难 点 之 一 。 以 据 库 的 应 用 能 力 培 养 为 主 要 目标 , 顾 兼 如 何 设 计 出 一 个 有 效 的 数 据 库 系统 , D A基本 能 力培 养 的要 求 和数 据库 前 沿进 是 数 据 库 工 作 者 的 重 要 任 务 。因此 , 数 据 B “ 展 简介 来组 织 教材 内 容 。 照 “ 论 、 践 、 库 设 计 ” 一 部 分 讲 解 数 据 库 设 计 过 程 的 6 按 理 实 这
数据库系统基础教程课后答案
Solutions Chapter 44.1.14.1.2a)b)In c we assume that a phone and address can only belong to a single customer (1-m relationship represented by arrow into customer).In d we assume that an address can only belong to one customer and a phone canexist at only one address.If the multiplicity of above relationships were m-to-n, the entity set becomesweak and the key ssNo of customers will be needed as part of the composite keyof the entity set.In c&d, we convert attributes phones and addresses to entity sets. Since entitysets often become relations in relational design,we must consider more efficient alternatives.Instead of querying multiple tables where key values are duplicated, we can also modify attributes:(i) Phones attribute can be converted into HomePhone, OfficePhone and CellPhone. (ii) A multivalued attribute such as alias can be kept as an attribute where asingle column can be used in relational design i.e. concatenate all values. SQLallows a query "like '%Junius%'" to search the multiple values in a column alias.4.1.34.1.4a)b)c)The relationship "played" between Teams and Players is similar to relationship "plays" between Teams and Players.4.1.54.1.6 The information about children can be ascertained from motherOf and fatherOf relationships. Attribute ssNo is required since names are not unique.4.1.74.1.8a)(b)4.1.9AssumptionsA Professor only works in at most one department.A course has at most one TA.A course is only taught by one professor and offered by one department.Students and professors have been assigned unique email ids.A course is uniquely identified by the course no, section no, and semester (e.g. cs157-3 spring 09).4.1.10Given that for each movie, a unique studio exists that produces the movie. Each star is contracted to at most one studio.But stars could be unemployed at a given time. Thus the four-way relationship in fig 4.6 can be easily into converted equivalent relationships.Redundancy: The owner address is repeated in AccSets and Addresses entity sets. Simplicity: AccSets does not serve any useful purpose and the design can be more simply represented by creating many-to-many relationship between Customers and Accounts.Right kind of element: The entity set Addresses has a single attribute address.A customer cannot have more than one address.Hence address should be an attribute of entity set Customers.Faithfulness: Customers cannot be uniquely identified by their names. In real world Customers would have a unique attribute such as ssNo or customerNo4.2.2Studios and Presidents can be combined into one entity set Studios withPresidents becoming an attribute of Studios under following circumstances:1. The Presidents entity set only contains a simple attribute viz. presidentName. Additional attributes specific to Presidents might justify making Presidentsinto an entity set.4.2.34.2.4 The entity sets should have single attribute.a) Stars: starNameb) Movies: movieNamec) Studios: studioName. However there exists a many-to-many relationship between Studios and Contracts. Hence, in addition, we need more information aboutstudios involved. If a contract always involves two studios, two attributes such as producingStudio and starStudio can replace theStudios entity set. If a contact can be associated with at most five studios, it may be possible to replace the Studios entity set by five attributes viz.studio1, studio2, studio3, studio4, and studio5. Alternately, a compositeattribute containing concatenation of all studio names in a contact can be considered. A separator character such as "$" can be used. SQL allows searchingof such an attribute using query like '%keyword%'From Augmentation rule of Functional Dependency,givenB -> M (B=Baby, M=Mother)thenBND -> M (N=Nurse, D=Doctor)Hence we can just put an arrow entering mother.a) Put an arrow entering entity set Mothers for the simplest solution (As in fig.4.4, where a multi-way relationship was allowed, even though Movies alone could identify the Studio). However, we can display more accurate information with below figure.Again from Augmentation rule of Functional Dependency,givenBM -> DthenBMN -> DThus we can just add an arrow entering Doctors to fig 4.15. Below figure represents more accurate information however.4.2.6a)b) Transitivity and Augmentation rules of Functional Dependency allow arrow entering Mothers from Births. However, a new relationship in below figure represents more accurate information.c)Design flaws in abc above 1. As suggested above, using Transitivity and Augmentation rules of Functional Dependency, much simpler design is possible.4.2.7In below figure there exists a many-to-one relationship between Babies and Births and another many-to-one relationship between Births and Mothers. From transitivity of relationships, there is a many-to-one relationship between Babies and Mothers. Hence a baby has a unique mother while a birth can allow more than one baby.4.3.1a)b)A captain cannot exist without a team. However a player can (free agent). A recently formed (or defunct) team can exist without players or colors.c)Children can exist without mother and father (unknown).4.3.2a)The keys of both E1 and E2 are required for uniquely identifying tuples in Rb)The key of E1c)The key of E2d)The key of either E1 or E24.3.3Special Case: All entity sets have arrows going into them i.e. all relationships are 1-to-1Any KiOtherwise: Combination of all Ki's where there does not exist an arrow going from R to Ei.4.4.1No, grade is not part of the key for enrollments. The keys of Students and Courses become keys of the weak entity set Enrollments.4.4.2It is possible to make assignment number a weak key of Enrollments but this is not good design (redundancy since multiple assignments correspond to a course).A new entity set Assignment is created and it is also a weak entity set. Hence the key attributes of Assignment will come from the strong entity sets to which Enrollments is connected i.e. studentID, dept, and CourseNo.4.4.3a)b)4.4.4a)4.5.1Customers(SSNo,name,addr,phone)Flights(number,day,aircraft)Bookings(custSSNo,flightNo,flightDay,row,seat)Relations for toCust and toFlt relationships are not required since the weak4.5.2(a)(b)Schema is changed. Since toCust is no longer an identifying relationship, SSNo is no longer a part of Bookings relation.Bookings(flightNo,flightDay,row,seat)ToCust(custSSNO,flightNo,flightDay,row,seat)The above relations are merged intoBookings(flightNo,flightDay,row,seat,custSSNo)However custSSNo is no longer a key of Bookings relation. It becomes a foreign4.5.3Ships(name, yearLaunched)SisterOf(name, sisterName)4.5.4(a)Stars(name,addr)Studios(name,addr)Movies(title,year,length,genre)Contracts(starName,movieTitle,movieYear,studioName,salary)Depending on other relationships not shown in ER diagram, studioName may not be required as a key of Contracts (or not even required as an attribute of Contracts).(b)Students(studentID)Courses(dept,courseNo)Enrollments(studentID,dept,courseNo,grade)(c)Departments(name)Courses(deptName,number)(d)Leagues(name)Teams(leagueName,teamName)Players(leagueName,teamName,playerName)4.6.1The weak relation Courses has the key from Depts along with number. Hence there is no relation for GivenBy relationship.(a)Depts(name, chair)Courses(number, deptName, room)LabCourses(number, deptName, allocation)(b) LabCourses has all the attributes of Courses.Depts(name, chair)Courses(number, deptName, room)(c) Courses and LabCourses are combined into one relation.Depts(name, chair)Courses(number, deptName, room, allocation)4.6.2(a)Person(name,address)ChildOf(personName,personAddress,childName,childAddress)Child(name,address,fatherName,fatherAddress,motherName,motherAddresss)Father(name,address,wifeName,wifeAddresss)Mother(name,address)Since FatherOf and MotherOf are many-one relationships from Child, there is no need for a separate relation for them. Similarly the one-one relationshipMarried can be included in Father (or Mother). ChildOf is a many-manyrelationship and needs a separate relation.However the ChildOf relation is not required since the relationship can be deduced from FatherOf and MotherOf relationships contained in Child relation. (b)A person cannot be both Mother and Father.Person(name,address)PersonChild(name,address)PersonChildFather(name,address)PersonChildMother(name,address)PersonFather(name,address)PersonMother(name,address)ChildOf(personName,personAddress,childName,childAddress)FatherOf(childName,childAddress,fatherName,fatherAddress)MotherOf(childName,childAddress,motherName,motherAddress)Married(husbandName,husbandAddress,wifeName,wifeAddress)The many-many ChildOf relationship again requires a relation.An entity belongs to one and only one class when using object-oriented approach. Hence, the many-one relations MotherOf and FatherOf could be added as attributes to PersonChild,PersonChildFather, and PersonChildMother relations.Similarly the Married relation can be added as attributes to PersonChildMother and PersonMother (or the corresponding father relations).(c) For the Person relation at least one of husband and wife attributes will be null.Person(personName,personAddress,fatherName,fatherAddress,motherName,motherAddres ss,wifeName,wifeAddresss,husbandName,husbandAddress)ChildOf(personName,personAddress,childName,childAddress)4.6.3(a)People(name,fatherName,motherName)Males(name)Females(name)Fathers(name)Mothers(name)ChildOf(personName,childName)(b)People(name)PeopleMale(name)PeopleMaleFathers(name)PeopleFemale(name)PeopleFemaleMothers(name)ChildOf(personName,childName)FatherOf(childName,fatherName)MotherOf(childName,motherName)People cannot belong to both male and female branch of the ER diagram.Moreover since an entity belongs to one and only one class when using object-oriented approach, no entity belongs to People relation.Again we could replace MotherOf and FatherOf relations by adding as attributesto PeopleMale,PeopleMaleFathers,PeopleFemale, and PeopleFemaleMothers relations.(c)People(name,fatherName,motherName)ChildOf(personName,childName)4.6.4(a)Each entity set results in one relation. Thus both the minimum and maximum number of relations is e.The root relation has a attributes including k keys. Thus the minimum number of attributes is a. All other relations include the k keys from root along withtheir a attributes. Thus the maximum number of attributes is a+k.(b)The relation for root will have a attributes. The relation representing the whole tree will have e*a attributes.The number of relations will depend on the shape of the tree. A tree of eentities where only one child exists(say left child only) would have the minimum number of relations. Thus below figure will only contain 4 subtrees that contain root E1,E1E2,E1E2E3, and E1E2E3E4. With e entity sets, minimum e relations are possible.The maximum number of subtrees result when all the entities(except root) are at depth 1. Thus below figure will contain 8 subtrees that contain rootE1,E1E2,E1E3,E1E4,E1E2E3,E1E3E4,E1E2E4,and E1E2E3E4. With e entity sets, maximum 2^(e-1) relations are possible.(c)The nulls method always results in one relation and contains attributes from all e entities i.e. e*a attributes.Summarizing for a,b, and c above;#Components #RelationsMin Max Min MaxMethodstraight-E/R a a e eobject-oriented a e*a e 2^(e-1)nulls e*a e*a 1 14.7.14.7.2a)b)c)d)4.7.34.7.5Males and Females subclasses are complete. Mothers and Fathers are partial. All subclasses are disjoint.4.7.7We convert the ternary relationship Contracts into three binary relationships between a new entity set Contracts and existing entity sets.4.7.9a)b)c)4.7.10A self-association ParentOf for entity set people has multiplicity 0..2 at parent role end.In a Library database, if a patron can loan at most 12 books, them multiplicity is 0..12.For a FullTimeStudents entity set, a relationship of multiplicity 5..* must exist with Courses (A student must take at least5 courses to be classified FullTime.4.8.1Customers(SSNo,name,addr,phone)Flights(number,day,aircraft)Bookings(row,seat,custSSNo,FlightNumber,FlightDay)Customers("SSNo",name,addr,phone)Flights("number","day",aircraft)Bookings(row,seat,"custSSNo","FlightNumber","FlightDay")4.8.2a)Movies(title,year,length,genre)Studios(name,address)Presidents(cert#,name,address)Owns(movieTitle,movieYear,studioName)Runs(studioName,presCert#)Movies("title","year",length,genre)Studios("name",address)Presidents("cert#",name,address)Owns("movieTitle","movieYear",studioName)Runs("studioName",presCert#)b)Since the subclasses are disjoint, Object Oriented Approach is used. The hierarchy is not complete. Hence four relations are required Movies(title,year,length,genre)MurderMysteries(title,year,length,genre,weapon)Cartoons(title,year,length,genre)Cartoon-MurderMysteries(title,year,length,genre,weapon)Movies("title","year",length,genre)MurderMysteries("title","year",length,genre,weapon)Cartoons("title","year",length,genre)Cartoon-MurderMysteries("title","year",length,genre,weapon)c)Customers(ssNo,name,phone,address)Accounts(number,balance,type)Owns(custSSNo,accountNumber)Customers("ssNo",name,phone,address)Accounts("number",balance,type)Owns("custSSNo","accountNumber")d)Teams(name,captainName)Players(name,teamName)Fans(name,favoriteColor)Colors(colorname)For Displays association,TeamColors(teamName,colorname)RootsFor(fanName,teamName)Admires(fanName,playerName)Teams("name",captainName)Players("name",teamName)Fans("name",favoriteColor)Colors("colorname")For Displays association,TeamColors("teamName","colorname")RootsFor("fanName","teamName")Admires("fanName","playerName")e)People(ssNo,name,fatherSSNo,motherSSNo)People("ssNo",name,fatherssNo,motherssNo)f)Students(email,name)Courses(no,section,semester,professorEmail)Departments(name)Professors(email,name,worksDeptName)Takes(letterGrade,studentEmail,courseNo,courseSection,courseSemester)Students("email",name)Courses("no","section","semester",professorEmail)Departments("name")Professors("email",name,worksDeptName)Takes(letterGrade,"studentEmail","courseNo","courseSection","courseSemester")4.8.3a)Each and every object is a member of exactly one subclass at leaf level. We have nine classes at the leaf of hierarchy. Hence we need nine relations.b)All objects only belong to one subclass and its ancestors. Hence, we need not consider every possible subtree but rather the total number of nodes in tree. Hence we need thirteen relations.c)We need all possible subtrees. Hence 218 relations are required.class Customer (key (ssNo)){attribute integer ssNo;attribute string name;attribute string addr;attribute string phone;relationship Set<Account> ownsAcctsinverse Account::ownedBy;};class Account (key (number)){attribute integer number;attribute string type;attribute real balance;relationship Set<Customer> ownedByinverse Customer::ownsAccts;};4.9.2a)Modify class Account to contain relationship Customer ownedBy (no Set)b)Also remove set in relationship ownsAccts of class Customer.c)ODL allows a collection of primitive types as well as structures. To class Customer add following attributes in place of simple attributes addr and phone: Set<string phone>Set<Struct addr{string street,string city,string state}>d)ODL allows structures and collections recursively.Set<Struct addr{string street,string city,string state},Set<string phone>>Collections are allowed in ODL. Hence, Colors Set can become an attribute of Teams.class Colors(key(colorname)){attribute string colorname;relationship Set<Fans> FavoredByinverse Fans::Favors;relationship set<Teams> DisplayedByinverse Teams::Displays;};class Teams(key(name)){attribute string name;relationship set<Colors> Displaysinverse Colors::DisplayedBy;relationship set<Players> PlayedByinverse Players::Plays;relationship PLayers CaptainedByinverse Platyers::Captains;relationship set<Fans> RootedByinverse Fans::Roots;};class Players(key(name)){attribute string name;relationship Set<Teams> Playsinverse Teams::PlayedBy;relationship Teams Captainsinverse Teams::CaptainedBy;relationship Set<Fans> AdmiredByinverse Fans::Admires;};class Fans(key(name)){attribute string name;relationship Colors Favorsinverse Colors::FavoredBy;relationship Set<Teams> RootedByinverse Teams::Roots;relationship Set<Players> Admiresinverse Players::AdmiredBy;};4.9.4class Person {attribute string name;relationship Person motherOfinverse Person::childrenOfFemale;relationship Person fatherOfinverse Person::childrenOfMale;relationship Set<Person> childreninverse Person::parentsOf;relationship Set<Person> childrenOfFemaleinverse Person::motherOf;relationship Set<Person> childrenOfMaleinverse Person::fatherOf;relationship Set<Person> parentsOfinverse Person::children;};4.9.5The struct education{string degree,string school,string date} cannot have duplication.Hence use of Sets does not make any different as compared to bags, lists, or arrays.Lists will allow faster access/queries due to the already sorted nature.4.9.6a)class Departments(key (name)) {attribute string name;relationship Courses offersinverse Courses::offeredBy;};class Courses(key (number,offeredBy)) {attribute string number;relationship Departments offeredByinverse Departments::offers;};b)class Leagues (key (name)) {attribute name;relationship Teams containsinverse Teams::belongs;};class Teams(key (name,belongs)) {attribute name,relationship Leagues belongsinverse Leagues::contains;relationship Players playinverse Players::plays;};class Players (key(number,plays)) {attribute number,relationship Teams playsinverse Teams::play;4.9.7class Students (key email) {attribute string email;attribute string name;relationship Courses isTAinverse Courses::TA;relationship Courses Takesinverse Courses::TakenBy;};class Professors (key email) {attribute string email;attribute string name;relationship Departments WorksForinverse Department::Works;relationship Courses Teachesinverse Courses::TaughtBy;};class Courses (key (no,semester,section)) {attribute string no;attribute string semester;attribute string section;relationship Students TAinverse Students::isTA;relationship Students TakenByinverse Students::Takes;relationship Professors TaughtByinverse Professors::Teaches;relationship Departments OfferedByinverse Departments::Offer;};class Departments (key name) {attribute name;relationship Courses Offerinverse Courses::OfferedBy;relationship Professors Worksinverse Professors::WorksFor;};4.9.8A relationship is its own inverse when for every attribute pair in the relationship, the inverse pair also exists. A relation with such a relationship is called symmetric in set theory. e.g. A relationship called SiblingOf in Person relation is its own inverse.4.10.1a)Customers(ssNo,name,addr,phone)Account(number,type,balance)Owns(ssNo,accountNumber)b)Accounts(number,balance,type,owningCustomerssNo)Customers(ssNo,name)Addresses(ownerssNo,street,state,city)Phones(ownerssNo,street,state,city,phonearea,phoneno)We can remove Addresses relation since its attributes are a subset of relation Phones.c)Fans(name,colors)RootedBy(fan_name,teamname)Admires(fan_name,playername)Players(name,teamname,is_captain)Teams(name)--remove subset of teamcolorTeamcolors(name,colorname)Colors(colorname)d)class Person {attribute string name;relationship Person motherOfinverse Person::childrenOfFemale;relationship Person fatherOfinverse Person::childrenOfMale;relationship Set<Person> childreninverse Person::parentsOf;relationship Set<Person> childrenOfFemaleinverse Person::motherOf;relationship Set<Person> childrenOfMaleinverse Person::fatherOf;relationship Set<Person> parentsOfinverse Person::children;};Person(name,mothername,fathername)The children relationship is many-many but the information can be deduced from Person relation. Hence below relation is redundant.Parent-Child(parent, child)4.10.2First consider each struct as if it were an atomic value i.e. key and value association pairs can be treated as two attributes. After applying normalization, the attributes can be replaced by the fields of the structs.4.10.3(a)Struct Card { string rank, string suit };(b)class Hand {attribute Set theHand;};(c)Hands(handId, rank, suit)Each tuple corresponds to one card of a hand. HandId is required key to identify a hand.class PokerHand{attribute Array Hand(Card card1,Card card2,Card card3,Cardcard4,Card card5)}PokerHandS(handId,rank1,suit1,,rank2,suit2,rank3,suit3,rank4,suit4,rank5,suit5) (e)class Deal {attribute Set <Struct PlayerHand { string Player, Hand theHand } > theDeal;}(f) PokerDeal consist of a player and array of five card deal.class PokerDeal{string Player,attribute Array Hand(Card card1,Card card2,Cardcard3,Card card4,Card card5)}(g) Above can similarly be represented by key player and a value consisting of five element array.(h)dealID is a key for Deals. Thus the relations for classes Deals and Hands are:Deals(dealID, player, handID)Hands(handID, rank, suit)A simpler relation Deals below can also represents the classes:Deals(dealID, player, rank, suit)(i)The relation Deals(dealID,card) cannot identify the hand to which a card belongs. Also two attributes are required for a card;its rank and suit.Deals(dealID, handID, rank, suit)4.10.4(a)C(a, f, g)(b)C(a, f, g, count)(c)C(a, f, g, position)(d)C(a, f, g, i, j)。
(完整版)数据库系统基础教程第八章答案
Section 1Exercise 8.1.1a)CREATE VIEW RichExec ASSELECT * FROM MovieExec WHERE netWorth >= 10000000;b)CREATE VIEW StudioPres (name, address, cert#) ASSELECT , MovieExec.address, MovieExec.cert# FROM MovieExec, Studio WHERE MovieExec.cert# = Studio.presC#;c)CREATE VIEW ExecutiveStar (name, address, gender, birthdate, cert#, netWorth) AS SELECT , star.address, star.gender, star.birthdate, exec.cert#, WorthFROM MovieStar star, MovieExec exec WHERE = ANDstar.address = exec.address;Exercise 8.1.2a)SELECT name from ExecutiveStar WHERE gender = ‘f’;b)SELECT from RichExec, StudioPres where = ;c)SELECT from ExecutiveStar, StudioPresWHERE Worth >= 50000000 ANDStudioPres.cert# = RichExec.cert#;Section 2Exercise 8.2.1The views RichExec and StudioPres are updatable; however, the StudioPres view needs to be created with a subquery.CREATE VIEW StudioPres (name, address, cert#) ASSELECT , MovieExec.address, MovieExec.cert# FROM MovieExecWHERE MovieExec.cert# IN (SELECT presCt# from Studio);Exercise 8.2.2a) Yes, the view is updatable.b)CREATE TRIGGER DisneyComedyInsertINSTEAD OF INSERT ON DisneyComediesREFERENCING NEW ROW AS NewRowFOR EACH ROWINSERT INTO Movies(title, year, length, studioName, genre)VALUES(NewRow.title, NewRow.year, NewYear.length, ‘Disney’, ‘comedy’);c)CREATE TRIGGER DisneyComedyUpdateINSTEAD OF UPDATE ON DisneyComediesREFERENCING NEW ROW AS NewRowFOR EACH ROWUPDATE Movies SET length NewRow.lengthWHERE title = NewRow.title AND year = NEWROW.year ANDstudionName = ‘Disney’ AND genre = ‘comedy’;Exercise 8.2.3a) No, the view is not updatable since it is constructed from two different relations.b)CREATE TRIGGER NewPCInsertINSTEAD OF INSERT ON NewPCREFERENCING NEW ROW AS NewRowFOR EACH ROW(INSERT INTO Product VALUES(NewRow.maker, NewRow.model, ‘pc’))(INSERT INTO PC VALUES(NewRow.model, NewRow.speed, NewRow.ram, NewRow.hd, NewRow.price));c)CREATE TRIGGER NewPCUpdateINSTEAD OF UPDATE ON NewPCREFERENCING NEW ROW AS NewRowFOR EACH ROWUPDATE PC SET price = NewPC.price where model = NewPC.model;d)CREATE TRIGGER NewPCDeleteINSTEAD OF DELETE ON NeePCREFERENCING OLD ROW AS OldRowFOR EACH ROW(DELETE FROM Product WHERE model = OldRow.model)(DELETE FROM PC where model = OldRow.model);Section 3Exercise 8.3.1a)CREATE INDEX NameIndex on Studio(name);b)CREATE INDEX AddressIndex on MovieExec(address);c)CREATE INDEX GenreIndex on Movies(genre, length);Section 4Exercise 8.4.1Exercise 8.4.2Q1 = SELECT * FROM Ships WHERE name = n;Q2 = SELECT * FROM Ships WHERE class = c;Q3 = SELECT * FROM Ships WHERE launched = y;I = InsertsIndexesNone Name Class Launched Name & Name & Class & ThreeSection 5Exercise 8.5.1Updates to movies that involves title or yearUPDATE MovieProd SET title = ‘newTitle’ where title=’oldTitle’ AND year = oldYear; UPDATE MovieProd SET year = newYear where title=’oldYitle’ AND year = oldYear;Update to MovieExec involving cert#DELETE FROM MovieProdWHERE (title, year) IN (SELECT title, yearFROM Movies, MovieExecWHERE cert# = oldCert# AND cert# = producerC#);INSERT INTO MovieProdSELECT title, year, nameFROM Movies, MovieExecWHERE cert# = newCert# AND cert# = producerC#;Exercise 8.5.2Insertions, deletions, and updates to the base tables Product and PC would require a modification of the materialized view.Insertions into Product with type equal to ‘pc’:INSERT INTO NewPCSELECT maker, model, speed, ram, hd, price FROM Product, PC WHEREProduct.model = newModel and Product.model = PC.model;Insertions into PC:INSERT INTO NewPCSELECT maker, ‘newModel’, ‘newSpeed’, ‘newRam’, ‘newHd’, ‘newPrice’FROM Product WHERE model = ‘newModel’;Deletions from Product with type equal to ‘pc’:DELETE FROM NewPC WHERE maker = ‘deletedMaker’ AND model=’deletedModel’; Deletions from PC:DELETE FROM NewPC WHERE model = ‘deletedModel’;Updates to PC:Update NewPC SET speed=PC.speed, ram=PC.ram, hd=PC.hd, price=PC.price FROM PC where model=pc.model;Update to the attribute ‘model’ needs to be treated as a delete and an insert. Updates to Product:Any changes to a Product tuple whose type is ‘pc’ need to be treated as a delete or an insert, or both.Exercise 8.5.3Modifications to the base tables that would require a modification to the materialized view: inserts and deletes from Ships, deletes from class, updates to a Class’ displacement. Deletions from Ship:UPDATE ShipStats SETdisplacement=((displacement * count) –(SELECT displacementFROM ClasssesWHERE class = ‘DeletedShipClass’)) / (count – 1),count = count – 1WHEREcountry = (SELECT country FROM C lasses WHERE class=’DeletedShipClass’); Insertions into Ship:Update ShipStat SETdisplacement=((displacement*count) +(SELECT displacement FROM ClassesWHERE class=’InsertedShipClass’)) / (count + 1),count = count + 1WHEREcountry = (SELECT country FROM Classes WHERE classes=’InsertedShipClass); Deletes from Classes:NumRowsDeleted = SELECT count(*) FROM ships WHERE class = ‘DeletedClass’; UPDATE ShipStats SETdisplacement = (displacement * count) - (DeletedClassDisplacement *NumRowsDeleted)) / (count – NumRowsDeleted),count = count – NumRowsDeletedWHERE country = ‘DeletedClassCountry’;Update to a Class’ displacement:N = SELECT count(*) FROM Ships where class = ‘UpdatedClass’;UPDATE ShipsStat SETdisplacement = ((displacement * count) + ((oldDisplacement – newDisplacement) * N))/countWHEREc ountry = ‘UpdatedClassCountry’;Exercise 8.5.4Queries that can be rewritten with the materialized view:Names of stars of movies produced by a certain producerSELECT starNameFROM StarsIn, Movies, MovieExecWHERE movieTitle = title AND movieYear = year AND producerC# = cert# AND name = ‘Max Bialystock’;Movies produced by a certain producerSELECT title, yearFROM Movies, MovieExecWhere produce rC# = cert# AND name = ‘George Lucas’;Names of producers that a certain star has worked withSELECT nameFROM Movies, MovieExec, StarsInWhere producerC#=cert# AND title=movieTitle AND year=movieYear AND starName=’Carrie Fisher’;The number of movies produced by given producerSELECT count(*)FROM Movies, MovieExecWHER E producerC#=cert# AND name = ‘George Lucas‘;Names of producers who also starred in their own moviesSELECT nameFROM Movies, StarsIn, MovieExecWHERE producerC#=cert# AND movieTitle = title AND movieYear = year AND = starName;The number of stars that have starred in movies produced by a certain producer SELECT count(DISTINCT starName)FROM Movies, StarsIn, MovieExecWHERE producerC#=cert# AND movieTitle = title AND movieYear = year AND n ame ‘George Lucas’;The number of movies produced by each producerSELECT name, count(*)FROM Movies, MovieExecWHERE producerC#=cert# GROUP BY name。
数据库课后习题完整答案
习题参考答案第1章习题参考答案一、选择题1. C2. B3. D4. C5. D6. A7. A8. B9. D、10. B 11. C 12. D 13. A 14. D 15. B二、填空题1. 数据库系统2. 关系3. 物理独立性4. 操作系统5. 数据库管理系统(DBMS)6. 多对多7. 独立性8. 完整性控制9. 逻辑独立性10. 关系模型11. 概念结构(逻辑)12. 树有向图二维表嵌套和递归13. 宿主语言(或主语言)14. 数据字典15. 单用户结构主从式结构分布式结构客户/服务器结构浏览器/服务器结构第2章习题参考答案一、选择题1. A2. C3. C4. B5. B6. C7. B8. D9. C 10. A 11. B 12. A 13. A 14. D 15. D二、填空题1. 选择(选取)2. 交3. 相容(或是同类关系)4. 并差笛卡尔积选择投影5. 并差交笛卡尔积6. 选择投影连接7. σf(R)8. 关系代数关系演算9. 属性10. 同质11. 参照完整性12. 系编号系名称,电话,办公地点13. 元组关系域关系14. 主键外部关系键15. R和S没有公共的属性三、简答7.σtno=’T1’(T)*TC*C)(1)∏cno,cn(σage>18∧Sex=’男’ (S))(2)∏sno,sn,dept(σtn=’李力’(T)*TC*C)(3)∏cno,cn,ct(σsno=’s1’(S)*SC*C)(4)∏cno,cn,score(σsn=’钱尔’(S)*SC*∏cno,cn(C)) (5)∏cno,cn,score(σtn=’刘伟’(T)*TC)(6)∏sn,cno(S*SC)÷∏cno(σsn=’李思’(S))*C)(7)∏cno,cn(C)-∏cno,cn(SC*((8)∏cno,cn,sno(C*SC)÷∏sno(S)σcno=’c1’∨cno=’c2’ (SC)) (9)∏sno,sn,cno(S*SC)*∏cno((10)∏sno,sn,cno(S*SC)÷∏cno(C)第3章习题参考答案一、填空题1.结构化查询语言(Structured Query Language)2.数据查询、数据定义、数据操纵、数据控制3.外模式、模式、内模式4.数据库、事务日志5.NULL/NOT NULL、UNIQUE约束、PRIMARY KEY约束、FOREIGNKEY约束、CHECK约束6.聚集索引、非聚集索引7.连接字段8.行数9.定义10.系统权限、对象权限11.基本表、视图12.(1)INSERT INTO S VALUES('990010','李国栋','男',19)(2)INSERT INTO S(No,Name) VALUES('990009', '陈平')(3)UPDATE S SET Name='陈平' WHERE No='990009'(4)DELETE FROM S WHERE No='990008'(5)DELETE FROM S WHERE Name LIKE '陈%'13.CHAR(8) NOT NULL14.o=o15.ALTER TABLE StudentADDSGrade CHAR(10)二、选择题1. B2. A3. C4. B5. C6. C7. B8. D9. A 10. D第4章习题参考答案一、选择题1. B2. B3. D4. B5. C6. D7. B8. D9. C 10. A二、填空题1. 超键(或超码)2. 正确完备3. 属性集X的闭包X +函数依赖集F的闭包F +4. 平凡的函数依赖自反性5. {AD→C} φ6. 2NF 3NF BCNF7. 无损连接保持函数依赖8. AB BC BD9. B→φB→B B→C B→BC10. B→C A→D D→C11. AB1NF12. AD3NF三、简答题1、2、3、4、5、解(1)根据F对属性分类:L类属性:BD。
数据库课后答案71737
数据库课后答案71737(总95页)--本页仅作为文档封面,使用时请直接删除即可----内页可以根据需求调整合适字体及大小--目录第1部分课程的教与学第2部分各章习题解答及自测题第1章数据库概论基本内容分析教材中习题1的解答自测题自测题答案第2章关系模型和关系运算理论基本内容分析教材中习题2的解答自测题自测题答案第3章关系数据库语言SQL基本内容分析教材中习题3的解答自测题自测题答案第4章关系数据库的规范化设计基本内容分析教材中习题4的解答自测题自测题答案第5章数据库设计与ER模型基本内容分析教材中习题5的解答自测题自测题答案第6章数据库的存储结构基本内容分析教材中习题6的解答第7章系统实现技术基本内容分析教材中习题7的解答自测题自测题答案第8章对象数据库系统基本内容分析教材中习题8的解答自测题自测题答案第9章分布式数据库系统基本内容分析教材中习题9的解答自测题自测题答案第10章中间件技术基本内容分析教材中习题10的解答自测题及答案第11章数据库与WWW基本内容分析教材中习题11的解答第12章 XML技术基本内容分析教材中习题12的解答第2部分各章习题解答及自测题第1章数据库概论基本内容分析本章的重要概念(1)DB、DBMS和DBS的定义(2)数据管理技术的发展阶段人工管理阶段、文件系统阶段、数据库系统阶段和高级数据库技术阶段等各阶段的特点。
(3)数据描述概念设计、逻辑设计和物理设计等各阶段中数据描述的术语,概念设计中实体间二元联系的描述(1:1,1:N,M:N)。
(4)数据模型数据模型的定义,两类数据模型,逻辑模型的形式定义,ER模型,层次模型、网状模型、关系模型和面向对象模型的数据结构以及联系的实现方式。
(5)DB的体系结构三级结构,两级映像,两级数据独立性,体系结构各个层次中记录的联系。
(6)DBMSDBMS的工作模式、主要功能和模块组成。
(7)DBSDBS的组成,DBA,DBS的全局结构,DBS结构的分类。
数据库课后题参考答案
数据库课后题参考答案编辑整理:尊敬的读者朋友们:这里是精品文档编辑中心,本文档内容是由我和我的同事精心编辑整理后发布的,发布之前我们对文中内容进行仔细校对,但是难免会有疏漏的地方,但是任然希望(数据库课后题参考答案)的内容能够给您的工作和学习带来便利。
同时也真诚的希望收到您的建议和反馈,这将是我们进步的源泉,前进的动力。
本文可编辑可修改,如果觉得对您有帮助请收藏以便随时查阅,最后祝您生活愉快业绩进步,以下为数据库课后题参考答案的全部内容。
学校有若干个系,每个系有各自的系号、系名和系主任;每个系有若干名教师和学生,教师有教师号、教师名和职称属性,每个教师可以担任若干门课程,一门课程只能由一位教师讲授,课程有课程号、课程名和学分,并参加多项项目,一个项目有多人合作,且责任轻重有个排名,项目有项目号、名称和负责人;学生有学号、姓名、年龄、性别,每个学生可以同时选修多门课程,选修有分数。
(1)请设计此学校的教学管理的E —R 模型。
(2)将E-R 模型转换为关系模型。
2)系 (系号,系名,系主任)教师 (教师号,教师名,职称,系号)学生(学号,姓名,年龄,性别,系号)项目(项目号,名称,负责人)课程(课号,课程名,学分,教师号)选修(课号,学号,分数)负责(教师号,项目号,排名)3、设有下图所示的医院组织。
试画出其E-R 图及关系模式并用关系代数方法写出下面之查询公式:① 找出外科病房所有医生姓名;② 找出管辖13号病房的主任姓名;③ 找出管辖病员李维德的医生姓名.关系模式:病房(编号、名称、所在位置、主任姓名)医生(编号、姓名、年龄、职称、管辖病房号)病人(病号、姓名、患何种病、病房号)答案:图3-1 某医院人员组织关系框图 位置 病房号 医生编号医生姓名 病人编号数据库课后题参考答案N 1 1 M①、②、(病房))③、()第三章 习题一、单项选择题1、如果要在Windows 平台上运行DB2应用程序访问运行在UNIX 上的数据库服务器,需要在Windows 上安装那种产品?( )A DB2 企业服务器版B DB2 个人版C DB2 连接器D DB2 运行时客户端答案:D2、下面那种产品不允许远程的客户端应用程序连接到该服务器?( )A DB2 快速版B DB2 个人版C DB2 企业服务器版D DB2 工作组服务器版答案:B3、一个软件公司要开发一个需要访问DB2 for Linux 和DB2 for z/OS 的应用程序。
第2章数据库基础教程(SQL-Server平台)[顾韵华][电子教案]
笛卡尔积(Cartesian Product )
• 5) 笛卡尔积的表示方法
– 笛卡尔积可表示为一个二维表。表中的每行对应一 个元组,表中的每列对应一个域。例如:
D1
D2
D1
D2
食品
食品
服装
服装
文具
文具
食品
食品
服装
服装
文具
文具
关系(Relation )
1) 关系
D1×D2×…×Dn 的 子 集 称 为 在 域 D1 , D2 , … , Dn上的关系,表示为 R(D1,D2,…,Dn)
0
司
31
100
数 据
食品
苹果汁
5.20
宇一饮料公 司
2009-0608
20
服装
休闲服
120. 天天服饰公 2000-01-
00
司
01
5
文具
签字笔
3.50
新新文化用 品制造厂
2000-0101
100
二维表的特点
(1)每个表具有表名。 (2)表由表头和若干行数据两部分构成。 (3)表有若干列,每列都有列名。 (4)同一列的值必须取自同一个域。 (5)每一行的数据代表一个实体的信息。
笛卡尔积(Cartesian Product )
• 4) 基数(Cardinal number)
– 若Di(i=1,2,…,n)为有限集,其基数 为mi(i=1,2,…,n),
– 则D1×D2×…×Dn的基数M为:
n
M mi i 1
在上例中,基数:2×2×3=12,即 D1×D2×D3共有2×2×3=12个元组
– 所有域的所有取值的一个组合 – 不能重复
数据库课后习题参考答案与解析.doc
第1章数据概述一.选择题1.下列关于数据库管理系统的说法,错误的是CA.数据库管理系统与操作系统有关,操作系统的类型决定了能够运行的数据库管理系统的类型B.数据库管理系统对数据库文件的访问必须经过操作系统实现才能实现C.数据库应用程序可以不经过数据库管理系统而直接读取数据库文件D.数据库管理系统对用户隐藏了数据库文件的存放位置和文件名2.下列关于用文件管理数据的说法,错误的是DA.用文件管理数据,难以提供应用程序对数据的独立性B.当存储数据的文件名发生变化时,必须修改访问数据文件的应用程序C.用文件存储数据的方式难以实现数据访问的安全控制D.将相关的数据存储在一个文件中,有利于用户对数据进行分类,因此也可以加快用户操作数据的效率3.下列说法中,不属于数据库管理系统特征的是CA.提供了应用程序和数据的独立性B.所有的数据作为一个整体考虑,因此是相互关联的数据的集合C.用户访问数据时,需要知道存储数据的文件的物理信息D.能够保证数据库数据的可靠性,即使在存储数据的硬盘出现故障时,也能防止数据丢失5.在数据库系统中,数据库管理系统和操作系统之间的关系是DA.相互调用B.数据库管理系统调用操作系统C.操作系统调用数据库管理系统D.并发运行6.数据库系统的物理独立性是指DA.不会因为数据的变化而影响应用程序B.不会因为数据存储结构的变化而影响应用程序C.不会因为数据存储策略的变化而影响数据的存储结构D.不会因为数据逻辑结构的变化而影响应用程序7.数据库管理系统是数据库系统的核心,它负责有效地组织、存储和管理数据,它位于用户和操作系统之间,属于AA.系统软件B.工具软件C.应用软件D.数据软件8.数据库系统是由若干部分组成的。
下列不属于数据库系统组成部分的是B A.数据库B.操作系统C.应用程序D.数据库管理系统9.下列关于客户/服务器结构和文件服务器结构的描述,错误的是DA.客户/服务器结构将数据库存储在服务器端,文件服务器结构将数据存储在客户端B.客户/服务器结构返回给客户端的是处理后的结果数据,文件服务器结构返回给客户端的是包含客户所需数据的文件C.客户/服务器结构比文件服务器结构的网络开销小D.客户/服务器结构可以提供数据共享功能,而用文件服务器结构存储的数据不能共享数据库是相互关联的数据的集合,它用综合的方法组织数据,具有较小的数据冗余,可供多个用户共享,具有较高的数据独立性,具有安全控制机制,能够保证数据的安全、可靠,允许并发地使用数据库,能有效、及时地处理数据,并能保证数据的一致性和完整性。
(2020年7月整理)数据库课后习题及答案.doc
数据库课后习题及答案习题一1.数据库处理技术经历了【人工管理、文件管理、数据库管理】以及分布式数据库管理四个发展等段。
2.在人工管理和文件管理阶段,程序设计【依赖于】数据表示。
3.在文件管理阶段,文件之间是相互【独立】的,在数据库管理阶段,文件之间是相互【联系】的。
4.使用数据库程序设计时,只需要告诉数据库管理系统【做什么】,而不需要告诉他【怎么做】。
5.在【文件】系统中,数据没有独立的操作界面,在【数据】系统中,数据具有独立的操作界面。
6.DBMS具有【安全性控制、一致性控制、并发性控制】和【数据库恢复】等管理控制功能。
7.分布式数据库系统除了具有一般数据库系统的优点之外,还具有【系统的可靠性高、地域范围广、数据量大、客户数多】等优点。
8.在实体中能作为码的属性称为【主属性】、否则称为【非主属性】。
9.实体之间的联系类型有三种,分别是【1对1、1对多】和【多对多】。
10.若实体A和B是1对多的联系,实体B和C是1对1的联系,则实体A和C是【1对多】的联系。
11.若实体A和B是1对多的联系,实体B和C是1对1的联系,则实体A和C是【1对多】的联系。
12.在非关系模型中,每个结点代表着一个【记录型】,每个父子联系代表着【1对多】联系。
13.在非关系模型中操作记录的方式是【过程】式的,在关系模型中,操作记录的方式是【集合】式的。
14.关系中的每一行称为一个【元组】,每一列称为一个【属性】。
15.假定一个关系中由n个元组,则某个列的当前全部取值的个数最少为【1】个,最多为【n】个。
16.关系数据库系统具有【数据结构】单一、采用【集合运算】、数据完全【独立】、【数学】理论支持等优点。
17.在对象数据模型中,对象具有【封装】性、【继承】性、和【多态】性。
18.数据库管理系统的下层支持软件是【操作系统】、上层软件是数据库应用【开发工具】。
19.数据库体系结构中包含的三级模式为【内模式、模式】和【外模式】三种。
数据库课后习题参考答案
1.2 数据库管理系统第1章数据概述一.选择题1.下列关于数据库管理系统的说法,错误的是CA.数据库管理系统与操作系统有关,操作系统的类型决定了能够运行的数据库管理系统的类型B.数据库管理系统对数据库文件的访问必须经过操作系统实现才能实现C.数据库应用程序可以不经过数据库管理系统而直接读取数据库文件D.数据库管理系统对用户隐藏了数据库文件的存放位置和文件名2.下列关于用文件管理数据的说法,错误的是DA.用文件管理数据,难以提供应用程序对数据的独立性B.当存储数据的文件名发生变化时,必须修改访问数据文件的应用程序C.用文件存储数据的方式难以实现数据访问的安全控制D.将相关的数据存储在一个文件中,有利于用户对数据进行分类,因此也可以加快用户操作数据的效率3.下列说法中,不属于数据库管理系统特征的是CA.提供了应用程序和数据的独立性B.所有的数据作为一个整体考虑,因此是相互关联的数据的集合C.用户访问数据时,需要知道存储数据的文件的物理信息D.能够保证数据库数据的可靠性,即使在存储数据的硬盘出现故障时,也能防止数据丢失5.在数据库系统中,数据库管理系统和操作系统之间的关系是DA.相互调用B.数据库管理系统调用操作系统C.操作系统调用数据库管理系统D.并发运行6.数据库系统的物理独立性是指DA.不会因为数据的变化而影响应用程序B.不会因为数据存储结构的变化而影响应用程序C.不会因为数据存储策略的变化而影响数据的存储结构D.不会因为数据逻辑结构的变化而影响应用程序7.数据库管理系统是数据库系统的核心,它负责有效地组织、存储和管理数据,它位于用户和操作系统之间,属于AA.系统软件B.工具软件C.应用软件D.数据软件8.数据库系统是由若干部分组成的。
下列不属于数据库系统组成部分的是B A.数据库B.操作系统C.应用程序D.数据库管理系统9.下列关于客户/服务器结构和文件服务器结构的描述,错误的是DA.客户/服务器结构将数据库存储在服务器端,文件服务器结构将数据存储在客户端B.客户/服务器结构返回给客户端的是处理后的结果数据,文件服务器结构返回给客户端的是包含客户所需数据的文件C.客户/服务器结构比文件服务器结构的网络开销小D.客户/服务器结构可以提供数据共享功能,而用文件服务器结构存储的数据不能共享数据库是相互关联的数据的集合,它用综合的方法组织数据,具有较小的数据冗余,可供多个用户共享,具有较高的数据独立性,具有安全控制机制,能够保证数据的安全、可靠,允许并发地使用数据库,能有效、及时地处理数据,并能保证数据的一致性和完整性。
数据库基础及应用课后习题答案
数据库基础及应用课后习题答案【篇一:数据库应用基础教程课后答案中国铁道出版社】1.选择题(1)数据库(db)、数据库系统(dbs)、数据库管理系统(dbms)三者之间的关系是( a )。
a.dbs 包括db 和 dbms b.dbms 包括db 和 dbsc.db 包括 dbs和 dbms d.dbs 就是db,也就是 dbms(2)设有部门和职员两个实体,每个职员只能属于一个部门,一个部门可以有多名职员,则部门与职员实体之间的联系类型是(b )。
a.m:n b.1:m c.m:k d.1:1(3)对于“关系”的描述,正确的是( d )。
a.同一个关系中允许有完全相同的元组b.同一个关系中元组必须按关键字升序存放d.同一个关系中不能出现相同的属性名(4)e-r 图用于描述数据库的( a )。
a.概念模型 b.数据模型c.存储模型 d.逻辑模型(5)在关系模型中,一个关键字( c )。
a.可以由多个任意属性组成b.至多由一个属性组成c.可以由一个或者多个其值能够唯一表示该关系模式中任何元组的属性组成d.可以由一个或者多个任意属性组成(6)现有如下关系:患者(患者编号,患者姓名,性别,出生日期,单位)医疗(患者编号,患者姓名,医生编号,医生姓名,诊断日期,诊断结果)其中,医疗关系中的外关键字是( a )。
a.患者编号 b.患者姓名c.患者编号和患者姓名 d.医生编号和患者编号(7)一个关系只有一个( d )。
a.候选关键字 b.外部关键字c.组合关键字 d.主关键字(8)下列标识符可以作为局部变量使用的是( c )。
a.[@myvar] b.my var c.@myvar d.@my var(9)transact-sql支持的一种程序结构语句是( a )。
a.begin?end b.if?then?elsec.do case d.dowhile(10)字符串常量使用( a )作为定界符。
a.单引号 b.双引号c.方括号 d.花括号2.填空题(1)数据库是在计算机系统中按照一定的方式组织、存储和应用的(数据集合)。
数据库基础教程(SQL Server平台)[顾韵华]第2章
• 3) 分量(Component)
– 笛卡尔积元素(d1,d2,…,dn)中的每一 个值di叫作一个分量。
电子工业出版社(《数据库基础教程(SQL Server平台)》配套电子教案)
笛卡尔积(Cartesian Product )
• 4) 基数(Cardinal number)
– 若Di(i= 1,2,…,n)为有限集,其基数 为mi(i=1,2,…,n), – 则D1×D2×…×Dn的基数M为:
电子工业出版社(《数据库基础教程(SQL Server平台)》配套电子教案)
2.2 关系操作
2.2.1 基本关系操作 2.2.2 关系数据语言分类 2.1.3 关系代数
电子工业出版社(《数据库基础教程(SQL Server平台)》配套电子教案)
2.2.1 基本关系操作
(1)查询:数据查询操作用于对关系数据进行各种检索。 它是一个数据库最基本的功能,通过查询,用户可以 访问关系数据库中的数据。查询可以在一个关系内或 多个关系间进行。关系查询的基本单位是元组分量, 查询即定位符合条件的元组。 (2)更新:数据更新操作包括插入、删除和修改三种。 数据删除的基本单位为元组,其功能是将指定关系内 的指定元组删除。数据插入的功能是在指定关系中插 入一个或多个元组。数据修改是在一个关系中修改指 定的元组属性值。
电子工业出版社(《数据库基础教程(SQL Server平台)》配套电子教案)
关系(Relation )
1) 关系
D1×D2×…×Dn 的子集称为在域 D1 , D2 , … , Dn上的关系,表示为 R(D1,D2,…,Dn) R:关系名 n:关系的目或度(Degree)
电子工业出版社(《数据库基础教程(SQL Server平台)》配套电子教案)
数据库基础教程课后习题答案顾韵华
数据库基础教程课后习题答案顾韵华1 / 17 习题11、简述数据库系统的特点。
答:数据库系统的特点有:1)数据结构化在数据库系统中,采⽤统⼀的数据模型,将整个组织的数据组织为⼀个整体;数据不再仅⾯向特定应⽤,⽽是⾯向全组织的;不仅数据内部是结构化的,⽽且整体是结构化的,能较好地反映现实世界中各实体间的联系。
这种整体结构化有利于实现数据共享,保证数据和应⽤程序之间的独⽴性。
2)数据共享性⾼、冗余度低、易于扩充数据库中的数据能够被多个⽤户、多个应⽤程序共享。
数据库中相同的数据不会多次重复出现,数据冗余度降低,并可避免由于数据冗余度⼤⽽带来的数据冲突问题。
同时,当应⽤需求发⽣改变或增加时,只需重新选择不同的⼦集,或增加数据即可满⾜。
3)数据独⽴性⾼数据独⽴性是由DBMS 的⼆级映像功能来保证的。
数据独⽴于应⽤程序,降低了应⽤程序的维护成本。
4)数据统⼀管理与控制数据库中的数据由数据库管理系统(DBMS )统⼀管理与控制,应⽤程序对数据的访问均经由DBMS 。
DBMS 提供四个⽅⾯的数据控制功能:并发访问控制、数据完整性、数据安全性保护、数据库恢复。
2、什么是数据库系统?答:在计算机系统上引⼊数据库技术就构成⼀个数据库系统(DataBase System ,DBS )。
数据库系统是指带有数据库并利⽤数据库技术进⾏数据管理的计算机系统。
DBS 有两个基本要素:⼀是DBS ⾸先是⼀个计算机系统;⼆是该系统的⽬标是存储数据并⽀持⽤户查询和更新所需要的数据。
3、简述数据库系统的组成。
答:数据库系统⼀般由数据库、数据库管理系统(及其开发⼯具)、数据库管理员(DataBase Administrator ,DBA )和⽤户组成。
4、试述数据库系统的三级模式结构。
这种结构的优点是什么?答:数据库系统的三级模式结构是指数据库系统是由外模式、模式和内模式三级构成,同时包含了⼆级映像,即外模式/模式映像、模式/内模式映像,如下图所⽰。
数据库理论习题及答案
一、单项选择1.现有学生关系Student,属性包括学号(Sno),姓名(Sname),所在系(Sdept),系主任姓名(Mname),课程名(Cname)和成绩(Grade)。
这些属性之间存在如下联系:一个学号只对应一个学生;一个学生只对应一个系;一个系只对应一个系主任;一个学生的一门课只对应一个成绩;学生名可以重复;系名不重复;课程名不重复。
则以下不正确的函数依赖是(C)。
A. Sno→SdeptB. Sno→MnameC. Sname→SdeptD. Sno Cname→Grade2. 下面关于函数依赖的描述,错误的是( D)。
A. 在函数依赖A→B中,A称为决定因素B. 在关系R中,属性B依赖于属性A,则说明当属性A的值确定之后,属性B的值也就随之确定C. 函数依赖具有传递性D. 在关系R中,如果属性A依赖于属性B,这种依赖正式记作:A→B3.现给定一个关系R的实例如下表,则可能是函数依赖的是( B)。
A. F1→F2B. F1 F2→F5C. F3 F4→F5D. F2 F3→F44. 关系R包含属性{A1,A2,A3,A4,A5},其中{A1,A2}为键码(key),则下面的说法正确的是(C )。
A. {A1}或者{A2}有可能单独成为R的键码B. {A1,A2,A3}必然也是R的键码C. R中绝不可能出现两个在A1、A2上取值完全相同的元组D. R的所有元组中,A1或者A2的值都是不能重复的5. 下面关于键码的说法,错误的是()。
A. 一个关系的键码是惟一的B. 一个关系的键码指定值之后,对应的元组也就确定了C. 关系R的键码的任何真子集都不可能是关系R的键码D. 在保存学生学籍信息处的关系,学生姓名对应的属性不适合单独作为键码6. 在给出的如下表所示关系实例中,有可能作为键码的是(C )。
A. {F1}B. {F3}C. {F1,F2}D. {F4}7. 已知关系R包含属性{A,B,C,D},R的键码为{A,B},则下面的选项哪一个是R的超键码()。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
习题11、简述数据库系统的特点。
答:数据库系统的特点有:1)数据结构化在数据库系统中,采用统一的数据模型,将整个组织的数据组织为一个整体;数据不再仅面向特定应用,而是面向全组织的;不仅数据内部是结构化的,而且整体是结构化的,能较好地反映现实世界中各实体间的联系。
这种整体结构化有利于实现数据共享,保证数据和应用程序之间的独立性。
2)数据共享性高、冗余度低、易于扩充数据库中的数据能够被多个用户、多个应用程序共享。
数据库中相同的数据不会多次重复出现,数据冗余度降低,并可避免由于数据冗余度大而带来的数据冲突问题。
同时,当应用需求发生改变或增加时,只需重新选择不同的子集,或增加数据即可满足。
3)数据独立性高数据独立性是由DBMS 的二级映像功能来保证的。
数据独立于应用程序,降低了应用程序的维护成本。
4)数据统一管理与控制数据库中的数据由数据库管理系统(DBMS )统一管理与控制,应用程序对数据的访问均经由DBMS 。
DBMS 提供四个方面的数据控制功能:并发访问控制、数据完整性、数据安全性保护、数据库恢复。
2、什么是数据库系统?答:在计算机系统上引入数据库技术就构成一个数据库系统(DataBase System ,DBS )。
数据库系统是指带有数据库并利用数据库技术进行数据管理的计算机系统。
DBS 有两个基本要素:一是DBS 首先是一个计算机系统;二是该系统的目标是存储数据并支持用户查询和更新所需要的数据。
3、简述数据库系统的组成。
答:数据库系统一般由数据库、数据库管理系统(及其开发工具)、数据库管理员(DataBase Administrator ,DBA )和用户组成。
4、试述数据库系统的三级模式结构。
这种结构的优点是什么?答:数据库系统的三级模式结构是指数据库系统是由外模式、模式和内模式三级构成,同时包含了二级映像,即外模式/模式映像、模式/内模式映像,如下图所示。
数据库应用1……外模式A 外模式B 模式应用2应用3应用4应用5……模式外模式/模式映像模式/内模式映像数据库系统的这种结构具有以下优点:(1)保证数据独立性。
将外模式与模式分开,保证了数据的逻辑独立性;将内模式与模式分开,保证了数据的物理独立性。
(2)有利于数据共享,减少了数据冗余。
(3)有利于数据的安全性。
不同的用户在各自的外模式下根据要求操作数据,只能对限定的数据进行操作。
(4)简化了用户接口。
按照外模式编写应用程序或输入命令,而不需了解数据库全局逻辑结构和内部存储结构,方便用户系统。
5、什么是数据的物理独立性与逻辑独立性?并说明其重要性。
答:(1)数据的物理独立性是指数据的物理结构(包括存储结构、存取方式等)的改变,存储设备的更换,物理存储的更换,存取方式改变等都不影响数据库的逻辑结构,从而不致引起应用程序的变化。
(2)数据的逻辑独立性是指数据库总体逻辑结构的改变,如修改数据模式,增加新的数据类型、改变数据间联系等,不需要相应修改应用程序。
(3)数据的独立性使得数据库中数据独立于应用程序而不依赖于应用程序,也就是说数据的逻辑结构、存储结构与存取方式的改变不影响应用程序。
相应的,数据的独立性也使得应用程序的编制不再依赖于数据的物理和逻辑结构,提高了应用程序的可移植性与鲁棒性。
从理论上说,数据的独立性可以使数据的组织和应用程序的编制完全分离。
6、数据库管理系统的功能主要有哪几方面?答:数据库管理系统的主要功能包括以下几个方面:(1)有效地组织、存取和维护数据。
(2)数据定义功能。
DBMS通过数据定义语言(Data Definition Language,DDL)定义数据库的各类数据对象,包括数据的结构、数据约束条件等。
(3)数据操纵功能。
DBMS提供数据操纵语言(Data Manipulation Language,DML),用户使用DML实现对数据库中的数据进行查询、增加、删除和修改等操作。
(4)数据库的事务管理和运行管理。
DBMS提供数据控制语言(Data Control Language,DCL),数据库管理员使用DCL实现对数据库的安全性保护、完整性检查、并发控制、数据库恢复等数据库控制功能。
(5)数据库的建立和维护功能。
(6)其他功能。
包括:数据库初始数据输入与转换、数据库转储、数据库重组、数据库性能监视与分析、数据通信等,这些功能通常由DBMS提供的实用程序或管理工具完成。
7、数据库系统的人员主要包括哪些?答:数据库系统的人员主要包括:数据库管理员、系统分析员和数据库设计人员、应用程序员和最终用户。
8、什么是数据模型?答:数据模型(Data Model)是一种抽象模型,是对现实世界数据特征的抽象。
9、什么是概念模型?E-R模型的三要素是什么?答:概念模型是面向用户的模型,是现实世界到机器世界的一个中间层次。
其基本特征是按用户观点对信息进行建模。
概念模型是现实世界到信息世界的抽象,是数据库设计人员与用户进行交流的工具。
E-R模型的三要素为:(1)实体(entity)实体是指客观存在并可相互区别的事物。
实体可以是人、事或物,也可以是抽象的概念。
例如:一件商品、一个客户、一份订单等都是实体。
(2)属性(attribute)实体通常由若干特征,每个特征称为实体的一个属性。
属性刻画了实体在某方面的特性。
例如:商品实体的属性可以有商品编号、商品类别、商品名称、生产商等。
(3)联系(relationship)现实世界中事物之间的联系反映在E-R模型中就是实体间的联系。
例如,订单就是客户和商品之间的联系。
10、举例说明联系的三种类型。
答:一对一联系(1:1):如果对于实体集A中的任一实体,在实体集B中至多有一个实体与之联系;反之亦然,则称实体集A与实体集B具有一对一联系,记为1:1。
例如:在公司中,一个部门只有一个经理,而一个经理只在一个部门任职,则部门与经理之间具有一对一联系。
一对多联系(1:n):如果对于实体集A中的任一实体,在实体集B中有n(n≥1)个实体与之联系;而对于实体集B中的每一个实体,实体集A中至多有一个实体与之联系,则称实体集A与实体集B具有一对多联系,记为1:n。
例如:在公司中,一个部门可有多个职工,而一个职工只在一个部门任职,则部门与职工之间具有一对多联系。
多对多联系(m:n):如果对于实体集A中的任一实体,在实体集B中有n(n≥1)个实体与之联系;而对于实体集B中的每一个实体,实体集A中有m(m≥1)个实体与之联系,则称实体集A与实体集B具有多对多联系,记为m:n。
例如:在商品订购中,一个客户可订购多种商品,而一种商品也可被多个客户订购,则客户与商品之间具有多对多联系。
11、什么是逻辑数据模型?逻辑数据模型的三要素是什么?答:逻辑数据模型是数据库管理系统呈现给用户的数据模型,即用户从数据库中看到的数据组织形式。
逻辑数据模型的三要素为:(1)数据结构数据结构是对系统静态特性的描述,主要描述数据库组成对象以及对象之间的联系。
数据结构是刻画数据模型最重要的方面。
因此在数据库系统中,通常按照其数据结构的类型来命名数据模型。
主要的数据模型有层次模型、网状模型和关系模型。
(2)数据操作数据操作指对数据库中各种对象(型)的实例(值)允许执行的操作及有关的操作规则,它是对数据库动态特性的描述。
数据库中的数据操作主要分为查询、更新两大类,其中数据更新主要是指对数据记录的增、删、改。
数据模型需要定义这些操作的语义、操作符号、操作规则及实现操作的相关语句。
(3)完整性约束完整性约束是指对数据的一组完整性规则的集合。
完整性规则是给定的数据模型中数据及其联系所具有的制约和存储规则,用以限定符合数据模型的数据库状态以及状态的变化,保证数据的正确、有效、相容。
12、简述关系模型的特点。
答:关系模型主要有以下特点:(1)关系模型建立在严格的数学基础之上。
(2)数据结构简单清晰,用户易懂易用。
关系模型的数据结构虽然简单,但却能表达丰富的语义,能够较好地描述现实世界的实体以及实体间的各种联系。
(3)数据物理存取路径对用户是透明的,有更高的数据独立性、更好的数据安全性。
习题21、解释以下术语:关系、元组、属性、码、域、分量、关系模式。
答:(1)关系:一个关系(relation)指一张二维表。
(2)元组:一个元组(tuple)指二维表中的一行。
(3)属性:一个属性(attribute)二维表中的一列,表中每列均有名称,即属性名。
(4)码:码(key)也称为键、关键字、关键码,指表中可惟一确定元组的属性或属性组合。
(5)域:域(domain)指属性的取值范围。
(6)分量:分量指元组中的一个属性值。
(7)关系模式:关系模式是对关系“型”的描述,通常表示为:关系名(属性1,…,属性n)。
2、解释关系数据库的“型”和“值”。
答:关系数据库的型即关系数据库模式,是对关系数据库结构的描述。
关系数据库模式包括若干域的定义以及在这些域上定义的若干关系模式。
通常以关系数据库中包含的所有关系模式的集合来表示关系数据库模式。
关系数据库的值是由关系数据库模式中的各关系模式在某一时刻对应的关系的集合。
3、解释空值的含义。
答:在关系元组中允许出现空值,空值表示信息的空缺,即未知的值或不存在值。
4、候选码应满足哪两个性质?答:候选码应满足惟一性和最小性两个性质:(1)惟一性。
对关系R的任两个元组,其在属性集K上的值是不同的。
(2)最小性。
属性集K=(A i,A j,…,A k)是最小集,即若删除K中的任一属性,K 都不满足最小性。
5、关系操作的特点是什么?答:关系操作的特点是集合操作,即操作的对象和结果都是关系。
6、基本的关系操作包括哪些?答:关系模型的基本操作包括查询和更新两大类:(1)数据查询操作用于对关系数据进行各种检索。
它是一个数据库最基本的功能,通过查询,用户可以访问关系数据库中的数据。
查询可以在一个关系内进行,也可以在多个关系间进行。
关系查询的基本单位是元组分量,查询即定位符合条件的元组。
(2)数据更新操作操作包括插入、删除和修改三种。
数据删除的基本单位为元组,其功能是将指定关系内的指定元组删除。
数据插入的功能在指定关系中插入一个或多个元组。
数据修改实在一个关系中修改指定的元组属性值。
7、关系代数的运算主要包含哪些?答:关系代数的运算可分为两类:(1)传统的集合运算。
其运算是以元组作为集合中元素来进行的,从关系的“水平”方向即行的角度进行。
包括并、差、交和笛卡尔积。
(2)专门的关系运算。
其运算不仅涉及行,也涉及列。
这类运算是为数据库的应用而引进的特殊运算,包括选择、投影、连接和除法等。
8、什么是数据完整性?如何实现数据完整性?试述关系完整性规则。
答:数据完整性是指数据库中的数据在逻辑上的正确性、有效性和相容性。