Beruflich Dokumente
Kultur Dokumente
Question 1
Given two relations: Student (Id, Name, Department Id), Course#, Section#, Day, Location), which of the following is
Incorrect a member of their product?
Mark 0.00 out
of 1.00 Select one:
a.
b.
c.
d.
Incorrect. This instance is a member of the union of the two relation, not their product.
The product relation is similar to the cartesian product of two sets. If a relation R is of dimension (recall that
dimension is the number of attributes) 3 and relation S is of dimension 3, then the product of R and S is a relation
that is of dimension 6. Thus, the product combines two relations, horizontally. Read the de nition of product
relations on page 6-10 of this chapter.
The correct answer is:
3 name3 sociology
4 name4 psychology
Select one:
a.
sociology
psychology
b.
math
math
sociology
psychology
c.
math
sociology
psychology
Correct. The projection of Student over Major is a relation that has values from the third column (the
column for Major). Since the instances of Major have a duplicate, the third column is not a valid relation and,
therefore the result of the projection is not all of the values from the third column. The result is the subset of
the third column values that consists of all the unique values and just one of the duplicate values.
d.
1 name1 math
2 name2 math
3 name3 sociology
3 name3 psychology
The projection over the attribute Major must result in a valid relation, because relational algebra relations are
closed by de nition (that is, the result must have unique rows). Since the set of values of Major contains duplicates,
the result cannot be the third column. The result is the subset of the third column values that consists of all the
unique values and just one of the duplicate values. Carefully read the de nition of projection on page 6-7 of this
chapter.
The correct answer is:
math
sociology
psychology
p y gy
Question 3 Let Full-Time and Part-Time be relations that contain information and records on student status:
Incorrect
Part-Time
Select one:
a.
b.
c.
Incorrect. This is not a valid relation because the rows are not unique.
d.
1 name1 math
2 name2 psychology
3 name3 math
4 name4 history
5 name5 latin
StudentB
2 name2 psychology
6 name6 geology
1 name1 math
7 name7 biology
3 name3 math
What is the result of the di erence of StudentA and StudentB, (StudentA - StudentB)?
Select one:
a.
4 name4 history
5 name5 latin
b.
6 name6 geology
7 name7 biology
Incorrect. This relation is (StudentB - StudentA) and not the relation (StudentA - StudentB).
c.
1 name1 math
2 name2 psychology
3 name3 math
d.
4 name4 history
4 name4 history
5 name5 latin
6 name6 geology
7 name7 biology
4 name4 history
5 name5 latin
Question 5 Relations and relational operators are similar to sets and set operations. 'Similar' can be de ned mathematically,
Incorrect which means that relational operators can be de ned in terms of set operations. For example, let R(A1, A2, A3) be a
Mark 0.00 out relation with attributes A1, A2, A3. Which of the following selections de nes πA3(R) is terms of sets? (For this
of 1.00 question, let coli represent the set of values of in column 3. Further, let rowi represent the set of values of rowi of
relation R).
Select one:
a. col3
b. row3
c. row3 ∩ col3
d. row3 ⋃ col3 Incorrect. row3 ⋃ col3 is the union of the values in row 3 and the values in column 3; it is not
the project of R over column 3.
Let relations and relational operators be 'similar' to sets and set operations via the correspondence shown below:
(for the diagram below, let column n be the set of values of the nth column):
The left side of the center line indicates the relational algebra domain; the arrows represent mapping to the
domain of sets, on the right side of the center line. The relational algebra domain (on the left side of the diagram)
de nes πA3(R) as the new relation S(A3), which is mapped to column3 in the set domain, where column3 is the set of
values of column3. Projection is de ned on page 6-9 of this chapter.
The correct answer is: col3
Question 6 Given the following table:
Incorrect
4 name4 geology
5 name5 latin
6 name6 geology
7 name7 biology
Which of the following is the set that is equivalent to πName (σA3 = geology(Student))? (Assume Ai is attribute i; rowi is
the set of values in the ith row; coli is the set of values in the ith column.)
Select one:
a. col2 - (row1 ⋃ row3)
πName (σA3 = geology(Student)) describes the names of the students who major in geology. The answer is 'name4,
name6'. The corresponding set answer is selection B, (row1 ⋃ row3) ∩ (col2). To verify this, perform the set
operations:
(row1 ⋃ row3) ∩ (col2) = ({4, name4, geology} ⋃ {6, name6, geology}) ∩ {name4, name5, name6, name7}
Review the de nitions in this chapter. If you need to, you can review sets and the set operations (union,
intersection, di erence) on this page.
The correct answer is: (row1 ⋃ row3) ∩ (col2)
Question 7 Given the following two relations and their records:
Incorrect
math1 instructor1 1
compsci2 instructor2 2
statistics1 instructor1 3
Instructor
For the value 'instructor name1', which of the following is a relational algebra description that corresponds to the
set that results from the following computation on rows and columns:
colA1 (Instructor) ∩ rowA2=instructor name1 (Instructor);
Select one:
a. σπA1(σA2 = instructor name1(Instructor))(Class) Incorrect. Given the value, 'instructor name1', the set that results
from the computation on rows and columns (in the question) is {1, 3}. Selection A. is a relational algebra
expression that results in the set (row1 ⋃ row3), which is not the set {1, 3}.
Performing the operations in the set description in the question, results in the set {1, 3}. This set represents the
answer to the query: nd the classes taught by instructor1. The relational algebra representation for this query is
selection D. πA3(σπA1(σA2 = instructor name1(Instructor))(Class)). Review the de nition of the relational operators on pages
6-7 to 6-9 of this chapter. Also review this lecture to 14:00.
The correct answer is: πA3(σπA1(σA2 = instructor name1(Instructor))(Class))
Question 8
Let the following two relations describe part of the information in a university database:
Incorrect
2 name2 Math
3 name3 Sociology
4 name4 History
Class
Students often desire to know which instructors teach at a particular campus. Which of the following selections is a
derived (compound) operation that lists the instructors who teach at campus1?
Select one:
a. πInstructor#(σLocation = campus1(Class))
c. (πInstructor#Name(σ(πInstructor#(σLocation = campus1 (Instructor)))(Class))) Incorrect. This rst selects the records that
have campus1 for location from the Instructor relation. However, 'Location' is not an attribute of the Instructor
relation. Therefore, this derived operation is invalid.
1 name1
2 name2
3 name3
4 name4
Class
100 campus1 1
130 campus1 3
140 campus3 3
Students often desire to know which instructors teach at a particular campus. For these speci c tables, which of
the following selections is the best derived operation to use to obtain a list of names of instructors who teach at
campus1?
For 'best', estimate the e ciency of the derived operations.
Select one:
a. πInstructor Name(Class ⋈ Instructor)) Correct. Since the value campus1 is uniquely determined by the
instructor#'s, a simple projection over Instructor Name produces the desired list. This is also the most e cient,
based on the number of relational operations and the size of the tables.
Due to the particular values for the attributes of the Instructor relation, campus1 is uniquely determined by the
values of the Instructor#. Thus, for the speci c tables, 'instructors assigned a class' = {instructor1, instructor3} =
'instructors teaching at campus1'. Then, an equi-join of the two tables produces a table that pairs instructor names
with instructor#'s, followed by a projection over Instructor Name, produces the desired list. The correct answer
uses two operations, a join and a projection. To review, read about theta-join on page 6-11 of this chapter. Equi-join
is a special case of theta-join, where the logical relation is equality. Since the tables are small, the number of
relational operators is a reasonable estimate of the e ciency of The join operation is more complicated than, and
uses more storage than selection or projection. Also review query optimization in this page on Relational Algebra.
The correct answer is: πInstructor Name(Class ⋈ Instructor))
Question 10
Let Student, Course, and Class be tables that de ne three relations and their tuples:
Incorrect
Number Name
number1 name1
number2 name2
Student
Id Name Credits
id1 name1 4
id2 name2 6
id3 name3 6
Course
c1 d1 3
c2 d2 4
Class
c1 A l1 number1 id1
c1 A l1 number1 id2
c1 B l1 number2 id3
c2 A l2 number1 id3
c2 A l2 number3 id2
that describes all student names enrolled in the class c1 A l1 taught by Instructor.name1, what is the corresponding
relational algebra description?
Select one:
a. πStudent.Name(σ(πStudent.Number(σCourse.Number=c1 and Section Number=A and Location=l1(Class)))(Student))
Review this video from 36:00 to the end, which goes over a relational calculus example. Also, review pages 6-11 and
6-12 of this chapter, which gives relational calculus descriptions for projection and selection relational algebra
expressions.
The correct answer is: πStudent.Name(σStudent.id∈ (πStudent.Id (σ(c1,A,l1,(πInstructor.Number(σInstructor.Name =
Instructor.name1(Instructor)))(Class)))(Student))