Sie sind auf Seite 1von 12

 Back to 'Unit 6 Assessment'

Started on Thursday, 3 October 2019, 6:05 PM


State Finished
Completed on Thursday, 3 October 2019, 6:07 PM
Time taken 1 min 44 secs
Grade 2.00 out of 10.00 (20%)

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.

1234 John Student M120 MWF

b.

1234 John Student Math M120 MWF

c.

1234 John Student Math M120 MWF Math

d.

1234 John Student Math

M120 MWF Math

 Incorrect. This instance is a member of the union of the two relation, not their product.

Your answer is incorrect.

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:

1234 John Student Math M120 MWF Math


Question 2
Let the following tuples be instances of the relation Student(ID, name, major).
Correct

Mark 1.00 out 1 name1 math


of 1.00
2 name2 math

3 name3 sociology

4 name4 psychology

What are the tuples of the relation ΠMajor(Student)?

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

Your answer is correct.

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

Mark 0.00 out


of 1.00
Full-Time

Student# Name Enrollment Date Major

1 name1 date1 math

2 name2 date2 soc

Part-Time

Student# Name Enrollment Date Major

6 name1 date1 math

7 name7 date7 soc

2 name2 date2 soc

What are the results of (Full-Time ∩ Part-Time)?

Select one:
a.

Student# Name Enrollment Date Major

2 name2 date2 soc

b.

Student# Name Enrollment Date Major

name1 date1 math

2 name2 date2 soc

c.

Student# Name Enrollment Date Major

2 name2 date2 soc

2 name2 date2 soc

 Incorrect. This is not a valid relation because the rows are not unique.

d.

Name Enrollment Date Major

name1 date1 math

Student# Name Enrollment Date Major

2 name2 date2 soc

Your answer is incorrect.


The intersection of two relations is the one that consists of the rows that are common to each relation. See the
de nition of relation intersection on page 6-9 of this chapter.
The correct answer is:

Student# Name Enrollment Date Major

2 name2 date2 soc


Question 4 Suppose two Student relations and their instances are given by the following tables:
Incorrect

Mark 0.00 out


of 1.00
StudentA

Student# Name Major

1 name1 math

2 name2 psychology

3 name3 math

4 name4 history

5 name5 latin

StudentB

Student# Name Major

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.

Student# Name Major

4 name4 history

5 name5 latin

b.

Student# Name Major

6 name6 geology

7 name7 biology

 Incorrect. This relation is (StudentB - StudentA) and not the relation (StudentA - StudentB).

c.

Student# Name Major

1 name1 math

2 name2 psychology

3 name3 math

d.

Student# Name Major

4 name4 history
4 name4 history

5 name5 latin

6 name6 geology

7 name7 biology

Your answer is incorrect.


The di erence of StudentA and StudentB consists of all rows that are in StudentA but not in StudentB. Thus, the
result is obtained by deleting rows that are in StudentB from the rows in StudentA. Review the de nition of the
di erence operator on page 6-9 of this chapter.

The correct answer is:

Student# Name Major

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.

Your answer is incorrect.

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

Mark 0.00 out


of 1.00
Student

Student# Name Major

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)

b. (row1 ⋃ row3) ∩ (col2)

c. (row1 ∩ col3) ⋃ (row4 ∩ col3)  Incorrect. This set is equal to 'geology'.

d. (R - (coli ⋃ col3)) - (row1 ⋃ row3)

Your answer is incorrect.

π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} 

= ({ 4, name4, geology, 6, name6, geology} ∩ {name4, name5, name6, name7}


= {name4, name6}

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

Mark 0.00 out


of 1.00
Class

Course Name Instructor# Class#

math1 instructor1 1

compsci2 instructor2 2

statistics1 instructor1 3

Instructor

Instructor# Instructor Name Department#

instructor1 instructor name1 100

instructor2 instructor name2 101

instructor3 instructor name3 102

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);

(rowA2=instructor1 (Class) ∩ colA3 (Class) = (row1 ⋃ row3) ∩ colA3 (Class) = {1,3}


Notation: let rowAi (S) or rowAi = v (S) represents the set of the values of row Ai or the set of values of the record(s) of
relation S that have a v for attribute Ai; and colAi (S) represents the set of values of attribute Ai of relation S.)

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}.

b. ππA1(σA2 = instructor name1(Instructor))(Class)

c. πA2(σπA1(σA2 = instructor name1(Instructor))(Class))

d. πA3(σπA1(σA2 = instructor name1(Instructor))(Class))

Your answer is incorrect.

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

Mark 0.00 out


of 1.00
Instructor

Instructor# Instructor Name Department

1 name1 Comp Sci

2 name2 Math

3 name3 Sociology

4 name4 History

Class

Course# Course Name SectionID Location Days Instructor#

100 cname100 A campus1 MWF 1

110 cname110 C campus2 TuTh 2

120 cname120 B campus2 MWF 4

100 cname100 B campus1 TuTh 3

110 cname110 A campus3 MWF 2

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))

b. (πInstructor# Name(σ(πInstructor#(σLocation = campus1 (Class)))(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.

d. (πInstructor#Name(σ(πInstructor#(σLocation = campus1 (Class)))(Instructor)))

Your answer is incorrect.


Since the tables are small, we know that the desired information is {name1, name3}. Performing the operations
from right to left: selection gets the two records from the Class relation that have campus1 for location. Projection
from these two records over the Instructor# attribute gives instructor#'s 1 and 3. Next, selection of records from
the Instructor relation, which have Instructor#'s of 1 and 3, results in two Instructor records. Last, projection over
the attribute Name for the two Instructor records results in name1 and name3. To review, read about selection and
projection on pages 6-7 and 6-8 of this chapter.

The correct answer is: (πInstructor#Name(σ(πInstructor#(σLocation = campus1 (Class)))(Instructor)))


Question 9 Let the following two relations describe part of the information in a university database:
Correct

Mark 1.00 out


of 1.00
Instructor

Instructor# Instructor Name

1 name1

2 name2

3 name3

4 name4

Class

Class# Location Instructor#

100 campus1 1

110 campus2 null

120 campus2 null

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.

b. πInstructor Name(Instructor ⋈(πInstructor#(Class)))

c. πInstructor#(σLocation = campus1(Class ⋈ Instructor)))

d. πInstructor Name(σLocation = campus1(Class ⋈ Instructor)))

Your answer is correct.

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

Mark 0.00 out


of 1.00
Instructor

Number Name

number1 name1

number2 name2

Student

Id Name Credits

id1 name1 4

id2 name2 6

id3 name3 6

Course

Number Description Credits

c1 d1 3

c2 d2 4

Class

Course.Number Section Number Location Instructor.Number Student.Id

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

Given the relational calculus description: 


{ Student.name |  (Student.name, Student.id)  Ɛ Student and

(c1, A, l1, Instructor.number, Student.id) Ɛ Class and


(Instructor.number, Instructor.name1) Ɛ Instructor },

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))

b. πStudent.Name(σStudent.id∈ (πStudent.Id (σ(c1,A,l1,(πInstructor.Number(σInstructor.Name = Instructor.name1(Instructor)))(Class)))


(Student))

c. πStudent.Id(σInstructor.Name=Instructor.name1(σCourse.Number=c1 ∧ Section Number=A ∧ Location=l1(Class)))

d. (πStudent.Id(Class - (σCourse.Number ≠ c1(Class)UσSection Number ≠ A(Class)UσLocation ≠ l1(Class)UσInstructor.Name ≠


Instructor.name1(Class))))  Incorrect. This selection results in the list of student id's of students enrolled in class
(c1 A l1) taught by the instructor Instructor.name1. However, a list of student names is required; not a list of
student Id's.
Your answer is incorrect.

πStudent.Name(σStudent.id∈(πStudent.Id (σ(c1,A,l1,(πInstructor.Number(σInstructor.Name = Instructor.name1(Instructor)))(Class)))(Student)) is the


correct answer. It selects the classes taught by Instructor.name1, using that instructor's Instructor.Number; then it
projects from those classes, the student id's of the students enrolled in them. Lastly, it gets the student names that
correspond to those student id's. 
Reading from right to left, select records (there is only one) from relation Instructor that contain Instructor.name1.
Next, project from Instructor over Instructor.Number to get the Instructor.Number for instructor Instructor.name1.
Next, select records from the relation Class containing (c1 A l1, Instructor.number1) and project on those records
over Student.Id to get the student numbers of the students enrolled in c1 A l1 taught by Instructor.name1. Next,
select from Student to get the student names that correspond to those student numbers. 

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))

Das könnte Ihnen auch gefallen