《数据库系统概念》第二章实践习题答案(英文版)

CHAPTER 2

2.1    Consider the relational database of Figure 2-14. What are the appropriate primary keys?

Answer: The answer is shown in Figure 2.1, with primary keys underlined.



2.2 Consider the foreign key constraint from the dept_name attribute of instructor to the department relation, Give examples of inserts and deletes to these relations, which can cause a violation of the foreign key constraint.

Answer:

  • Inserting a tuple:        (10111, Ostrom, Economics, 110,000)         into the instructor table, where the department table does not have the department Economics, would violate the foreign key constraint.
  • Deleting the tuple:        (Biology, Watson, 90000)         from the department table, where at least one student or instructor tuple has dept_name as Biology, would violate the foreign key constraint.


2.3 Consider the time_slot relation. Given that a particular time slot can meet more than once in a week, explain why day and start_time are part of the primary key of this relation, while end_time is not.

Answer: The attributes day and start_time are part of the primary key since a particular class will most likely meet on several different days, and  may even meet more than once in a day. However, end_time is not part of the primary key since a particular class that starts at a particular time on a particular day cannot end  at more than one time.


2.4 In the instance of instructor of instructor shown in Figure 2-1, no two instructors have the same name. From this, can we conclude that name can be used as a superkey (or primary key) of instructor?

Answer: No. For this possible instance of the instructor table the names are unique, but in general this may not be always the case (unless the university has a rule that two instructors cannot have the same name, which is a rather unlikely scenario).


2.5 What is the result of first performing the cross product of student and advisor, and them performing a selection operation on the result with the predicate s_id  = ID? (Using the symbolic notation of relational algebra, this query can be written as σs_id=ID(student × advisor).)

Answer: The result attributes include all attribute values of student followed by all attributes of advisor. The tuples in the result are as follows. For each student who has an advisor, the result has a row containing that students attributes, followed by an s_id attribute identical to the student ID attribute, followed by the i_id attribute containing the ID of the students advisor.

Students who do not have an advisor will not appear in the result. A student who has more than one advisor will appear a corresponding number of time in the result.


2.6 Consider the following expression, which use the result of a relational algebra operation as the input to another operation. For each expression, explain in words what the expression does.

a. σyear2009(takes) ∞ student

b. σyear2009(takes ∞ student)

c. ID, name, course_id(student ∞ takes)

Answer:

a. For each student who takes at least one course in 2009, display the students information along with the information about what courses the student took. The attributes in the result are:

ID, name, dept_name, tot_cred, course_id, section_id, semester, year, grade

b. Same as (a); selection can be done before the join operation.

c. Provide a list of consisting of

ID, name, course_id

  of all students who took any course in the university.


2.7 Consider the relational database of Figure 2-14. Give an expression in the relational algebra to express each of the following queries:

a. Find the names of all employees who live in city “Miami”.

b. Find the names of all employees whose salary is greater than $100,000.

c. Find the names of all employees who live in “Miami” and whose salary is greater than $100,000.

Answer:

a. ∏name (σcity = Miami (employee))

b. ∏name(σsalary > 100000 (employee))

c. ∏name(σcity = Miami ∧ salary > 100000 (employee))


2.8 Consider the bank database of Figure 2-15. Give an expression in the relational algebra for each of the following queries.

a. Find the names of all branches located located in “Chicago”.

b. Find the names of all borrowers who have a loan in branch “Downtown”

Answer:

a. ∏branch_name(σbranch_city = Chicago(branch))

b. ∏customer_name(σbranch_name = Downtown(borrower ∞ loan))

数据库系统概念(杨冬青)习题答案Chapter 1 provides a general overview of the nature and purpose of database systems. The most important concept in this chapter is that database systems allow data to be treated at a high level of abstraction. Thus, database systems differsignificantly from the file systemsand general purpose programming environments with which students are already familiar. Another important aspect of the chapter is to provide motivation for the use of database systems as opposed to application programs built on top of file systems. Thus, the chapter motivates what the student will be studying in the rest of the course. The idea of abstraction in database systems deserves emphasis throughout, not just in discussion of Section 1.3. The overview of the structure of databases is, of necessity, rather brief, and is meant only to give the student a rough idea of some of the concepts. The student may not initially be able to fully appreciate the concepts described here, but should be able to do so by the end of the course. The specifics of the E-R, relational, and object-oriented models are covered in later chapters. These models can be used in Chapter 1 to reinforce the concept of abstraction, with syntactic details deferred to later in the course. If students have already had a course in operating systems, it is worthwhile to point out how the OS and DBMS are related. It is useful also to differentiate between concurrency as it is taught in operating systems courses (with an orientation towardsfiles, processes,and physical resources)and database concurrency control (with an orientation towards granularity finer than the file level, recoverable transactions, and resources accessed associatively rather than physically). If students are familiar with a particular operating system, that OS’s approach to concurrent file access may be used for illustration.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值