数据库第五版课后答案.doc_第1页
数据库第五版课后答案.doc_第2页
数据库第五版课后答案.doc_第3页
数据库第五版课后答案.doc_第4页
数据库第五版课后答案.doc_第5页
已阅读5页,还剩87页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

INSTRUCTORS MANUALTO ACCOMPANYDatabaseSystem ConceptsFifth EditionAbraham SilberschatzYale UniversityHenry F. KorthLehigh UniversityS. SudarshanIndian Institute of Technology, BombayCopyright_c 2005 A. Silberschatz, H. Korth, and S. SudarshanContentsPreface 1Chapter 1 IntroductionExercises 3Chapter 2 RelationalModelExercises 7Chapter 3 SQLExercises 11Chapter 4 Advanced SQLExercises 19Chapter 5 Other Relational LanguagesExercises 23Chapter 6 Database Design and the E-R ModelExercises 33iiiiv ContentsChapter 7 Relational Database DesignExercises 41Chapter 8 Application Design and DevelopmentExercises 47Chapter 9 Object-Based DatabasesExercises 51Chapter 10 XMLExercises 55Chapter 11 Storage and File StructureExercises 61Chapter 12 Indexing and HashingExercises 65Chapter 13 Query ProcessingExercises 69Chapter 14 Query OptimizationExercises 75Chapter 15 TransactionsExercises 79Chapter 16 Concurrency ControlExercises 83Chapter 17 Recovery SystemExercises 89Contents vChapter 18 Data Analysis and MiningExercises 93Chapter 19 Information RetrievalExercises 99Chapter 20 Database-System ArchitecturesExercises 101Chapter 21 Parallel DatabasesExercises 105Chapter 22 Distributed DatabasesExercises 109Chapter 23 Advanced Application DevelopmentExercises 115Chapter 24 Advanced Data Types and New ApplicationsExercises 119Chapter 25 Advanced Transaction ProcessingExercises 123PrefaceThis volume is an instructors manual for the 5th edition of Database System Conceptsby Abraham Silberschatz, Henry F. Korth and S. Sudarshan. It contains answers tothe exercises at the end of each chapter of the book. Before providing answers to theexercises for each chapter, we include a few remarks about the chapter. The nature ofthese remarks vary. They include explanations of the inclusion or omission of certainmaterial, and remarks on how we teach the chapter in our own courses. The remarksalso include suggestions on material to skip if time is at a premium, and tips onsoftware and supplementary material that can be used for programming exercises.The Web home page of the book, at , contains a varietyof useful information, including up-to-date errata, online appendices describing thenetwork data model, the hierarchical data model, and advanced relational databasedesign, and model course syllabi. We will periodically update the page with supplementarymaterial that may be of use to teachers and students.We provide a mailing list through which users can communicate among themselvesand with us. If you wish to use this facility, please visit the following URL andfollow the instructions there to subscribe:/mailman/listinfo/db-book-listThe mailman mailing list system provides many benefits, such as an archive of postings,and several subscription options, including digest and Web only. To send messagesto the list, send e-mail to:We would appreciate it if you would notify us of any errors or omissions in thebook, as well as in the instructors manual. Internet electronic mail should be addressedto . Physical mail may be sent to Avi Silberschatz, YaleUniversity, 51 Prospect Street, New Haven, CT, 06520, USA.12 PrefaceAlthough we have tried to produce an instructors manual which will aid all ofthe users of our book as much as possible, there can always be improvements. Thesecould include improved answers, additional questions, sample test questions, programmingprojects, suggestions on alternative orders of presentation of the material,additional references, and so on. If you would like to suggest any such improvementsto the book or the instructors manual, we would be glad to hear from you.All contributions that we make use of will, of course, be properly credited to theircontributor.This manual is derived from the manuals for the earlier editions. The manual forthe 4th edition was prepared by Nilesh Dalvi, Sumit Sanghai, Gaurav Bhalotia andArvind Hulgeri. The manual for the 3rd edition was prepared by K. V. Raghavan withhelp from Prateek R. Kapadia. Sara Strandtman helped with the instructor manualfor the 2nd and 3rd editions, while Greg Speegle and Dawn Bezviner helped us toprepare the instructors manual for the 1st edition.A. S.H. F. K.S. S.Instructor Manual Version 5.0.0C H A P T E R 1IntroductionExercises1.5 List four applications which you have used, that most likely used a databasesystem to store persistent data.Answer: No answer1.6 List four significant differences between a file-processing system and a DBMS.Answer: Some main differences between a database management system anda file-processing system are: Both systems contain a collection of data and a set of programs which accessthat data. A database management system coordinates both the physicaland the logical access to the data, whereas a file-processing system coordinatesonly the physical access. A database management system reduces the amount of data duplication byensuring that a physical piece of data is available to all programs authorizedto have access to it,whereas data written by one program in a file-processingsystem may not be readable by another program. A database management system is designed to allow flexible access to data(i.e., queries), whereas a file-processing system is designed to allow predeterminedaccess to data (i.e., compiled programs). A database management system is designed to coordinate multiple usersaccessing the same data at the same time. A file-processing systemis usuallydesigned to allow one or more programs to access different data files atthe same time. In a file-processing system, a file can be accessed by twoprograms concurrently only if both programs have read-only access to thefile.1.7 Explain the difference between physical and logical data independence.Answer:34 Chapter 1 Introduction Physical data independence is the ability to modify the physical schemewithout making it necessary to rewrite application programs. Such modificationsinclude changing fromunblocked to blocked record storage, or fromsequential to random access files. Logical data independence is the ability to modify the conceptual schemewithout making it necessary to rewrite application programs. Such a modificationmight be adding a field to a record; an application programs viewhides this change from the program.1.8 List five responsibilities of a database management system. For each responsibility,explain the problems that would arise if the responsibility were not discharged.Answer: A general purpose database manager (DBM) has five responsibilities:a. interaction with the file manager.b. integrity enforcement.c. security enforcement.d. backup and recovery.e. concurrency control.If these responsibilities were not met by a given DBM (and the text pointsout that sometimes a responsibility is omitted by design, such as concurrencycontrol on a single-user DBM for a micro computer) the following problems canoccur, respectively:a. No DBM can do without this, if there is no file manager interaction thennothing stored in the files can be retrieved.b. Consistency constraints may not be satisfied, account balances could go belowthe minimum allowed, employees could earn too much overtime (e.g.,hours 80) or, airline pilots may fly more hours than allowed by law.c. Unauthorized users may access the database, or users authorized to accesspart of the database may be able to access parts of the database for whichthey lack authority. For example, a high school student could get accessto national defense secret codes, or employees could find out what theirsupervisors earn.d. Data could be lost permanently, rather than at least being available in a consistentstate that existed prior to a failure.e. Consistency constraints may be violated despite proper integrity enforcementin each transaction. For example, incorrect bank balances might bereflected due to simultaneous withdrawals and deposits, and so on.1.9 List at least two reasonswhy database systems support data manipulation usinga declarative query language such as SQL, instead of just providing a a libraryof C or C+ functions to carry out data manipulation.Answer: No answer1.10 Explain what problems are caused by the design of the table in Figure 1.5.Answer: No answerExercises 51.11 What are five main functions of a database administrator?Answer: Five main functions of a database administrator are: To create the scheme definition To define the storage structure and access methods To modify the scheme and/or physical organization when necessary To grant authorization for data access To specify integrity constraintsC H A P T E R 2Relational ModelExercises2.4 Describe the differences in meaning between the terms relation and relation schema.Answer: A relation schema is a type definition, and a relation is an instanceof that schema. For example, student (ss#, name) is a relation schema andss# name123-45-6789 Tom Jones456-78-9123 Joe Brownis a relation based on that schema.2.5 Consider the relational database of Figure 2.35, where the primary keys are underlined.Give an expression in the relational algebra to express each of the followingqueries:a. Find the names of all employees who work for First Bank Corporation.b. Find the names and cities of residence of all employees who work for FirstBank Corporation.c. Find the names, street address, and cities of residence of all employees whowork for First Bank Corporation and earn more than $10,000 per annum.d. Find the names of all employees in this database who live in the same cityas the company for which they work.e. Assume the companies may be located in several cities. Find all companieslocated in every city in which Small Bank Corporation is located.Answer:a. person-name (company-name = “First Bank Corporation” (works)78 Chapter 2 Relational Modelemployee (person-name, street, city)works (person-name, company-name, salary)company (company-name, city)manages (person-name, manager-name)Figure 2.35. Relational database for Exercises 2.1, 2.3 and 2.9.b. person-name, city (employee _(company-name = “First Bank Corporation” (works)c. person-name, street, city(company-name = “First Bank Corporation” salary 10000)works _ employee)d. person-name (employee _ works _ company)e. Note: Small Bank Corporation will be included in each pany-name (company (city (company-name=“Small Bank Corporation” (company)2.6 Consider the relation of Figure 2.20, which shows the result of the query “Findthe names of all customers who have a loan at the bank.” Rewrite the queryto include not only the name, but also the city of residence for each customer.Observe that now customer Jackson no longer appears in the result, even thoughJackson does in fact have a loan from the bank.a. Explain why Jackson does not appear in the result.b. Suppose that you want Jackson to appear in the result. How would youmodify the database to achieve this effect?c. Again, suppose that you want Jackson to appear in the result.Write a queryusing an outer join that accomplishes this desire without your having tomodify the database.Answer: The rewritten query iscustomer-name,customer-city,amount(borrower _ loan _ customer)a. Although Jackson does have a loan, no address is given for Jackson in thecustomer relation. Since no tuple in customer joins with the Jackson tuple ofborrower, Jackson does not appear in the result.b. The best solution is to insert Jacksons address into the customer relation. Ifthe address is unknown, null values may be used. If the database systemdoes not support nulls, a special value may be used (such as unknown) forJacksons street and city. The special value chosen must not be a plausiblename for an actual city or street.c. customer-name,customer-city,amount(borrower _ loan) _ customer)2.7 Consider the relational database of Figure 2.35. Give an expression in the relationalalgebra for each request:a. Give all employees of First Bank Corporation a 10 percent salary raise.Exercises 9b. Give allmanagers in this database a 10 percent salary raise, unless the salarywould be greater than $100,000. In such cases, give only a 3 percent raise.c. Delete all tuples in the works relation for employees of Small Bank Corporation.Answer:a. works person-name,company-name,1.1salary(company-name=“First Bank Corporation”)(works) (works company-name=“First Bank Corporation”(works)b. The same situation arises here. As before, t1, holds the tuples to be updatedand t2 holds these tuples in their updated form.t1 works.person-name,company-name,salary(works.person-name=manager-name(works manages)t2 works.person-name,company-name,salary1.03(t1.salary 1.1 100000(t1)t2 t2 (works.person-name,company-name,salary1.1(t1.salary 1.1 100000(t1)works (works t1) t2c. works works companyname=“Small Bank Corporation”(works)2.8 Using the bank example, write relational-algebra queries to find the accountsheld by more than two customers in the following ways:a. Using an aggregate function.b. Without using any aggregate functions.Answer:a. t1 account-numberGcount customer-name(depositor)account-number _num-holders2 _account-holders(account-number,num-holders)(t1)_b. t1 (d1(depositor) d2(depositor) d3(depositor)t2 (d1.account-number=d2.account-number=d3.account-number)(t1)d1.account-number(d1.customer-name_=d2.customer-name d2.customer-name_=d3.customer-name d3.customer-name_=d1.customer-name)(t2)2.9 Consider the relational database of Figure 2.35. Give a relational-algebra expressionfor each of the following queries:a. Find the company with the most employees.b. Find the company with the smallest payroll.c. Find those companies whose employees earn a higher salary, on average,than the average salary at First Bank Corporation.Answer:10 Chapter 2 Relational Modela. t1 company-nameGcount-distinct person-name(works)t2 maxnum-employees(company-strength(company-name,num-employees)(t1)company-name(t3(company-name,num-employees)(t1) _ t4(num-employees)(t2)b. t1 company-nameGsum salary(works)t2 minpayroll(company-payroll(company-name,payroll)(t1)company-name(t3(company-name,payroll)(t1) _ t4(payroll)(t2)c. t1 company-nameGavg salary(works)t2 company-name = “First Bank Corporation”(t1)pany-name(t3(company-name,avg-salary)(t1)_t3.avg-salary first-bank.avg-salary (first-bank(company-name,avg-salary)(t2)2.10 List two reasons why null values might be introduced into the database.Answer: Nulls may be introduced into the database because the actual valueis either unknown or does not exist. For example, an employee whose addresshas changed and whose new address is not yet known should be retained witha null address. If employee tuples have a composite attribute dependents, anda particular employee has no dependents, then that tuples dependents attributeshould be given a null value.2.11 Consider the following relational schemaemployee(empno, name, office, age)books(isbn, title, authors, publishe r)loan(empno, isbn, date)Write the following queries in relational algebra.a. Find the names of employees who have borrowed a book published byMcGraw-Hill.b. Find the names of employees who have borrowed all books published byMcGraw-Hill.c. Find the names of employees who have borrowed more than five differentbooks published by McGraw-Hill.d. For each publisher, find the names of employees who have borrowed morethan five books of that publisher.Answer: No answerC H A P T E R 3SQLExercises3.8 Consider the insurance database of Figure 3.11, where the primary keys are underlined.Construct the following SQL queries for this relational database.a. Find the number of accidents in which the cars belonging to “John Smith”were involved.b. Update the damage amount for the car with license number “AABB2000” inthe accident with report number “AR2197” to $3000.Answer: Note: The participated relation relates drivers, cars, and accidents.a. SQL query:select count (distinct *)from accidentwhere exists(select *from participated, personwhere participated.driver id = person.driver idand = John Smithand accident.report number = participated.report number)b. SQL query:update participatedset damage amount = 3000where report number = “AR2197” and driver id in(select driver idfrom ownswhere license = “AABB2000”)1112 Chapter 3 SQLperson (driver id, name, address)car (license, model, year)accident (report number, date, location)owns (driver id, license)participated (driver id, car, report number, damage amount)Figure 3.11. Insurance database.employee (employee name, street, city)works (employee name, company name, salary)company (company name, city)manages (employee name, manager name)Figure 3.12. Employee database.3.9 Consider the employee database of Figure 3.12, where the primary keys are underlined.Give an expression in SQL for each of the following queries.a. Find the names of all employees who work for First Bank Corporation.b. Find all employees in the database who live in the same cities as the companiesfor which they work.c. Find all employees in the database who live in the same cities and on thesame streets as do their managers.d. Find all employees who earn more

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论