Question: Q 2 . [ 5 9 marks ] You are given the following three relations in a university database as below ( with primary keys
Q marks You are given the following three relations in a university database as below
with primary keys underlined:
INSTRUCTOR Id Name, DeptName, Salary
COURSE Cid Name
TEACHES Id Cid, Semester, Year
The relation INSTRUCTOR has tuples, and tuples fit into one block; the relation COURSE
has tuples, and tuples fit into one block; the relation TEACHES has tuples, and
tuples fit into one block. All records are sorted in ascending order of the primary keys of the table
on disk TEACHES is first sorted on Id and then on Cid if two records have the same Id Assume
that the INSTRUCTOR Id ranges from to COURSE Cid from to It is assumed that a
relation is stored on disk consecutively. Please answer the following questions and show your
calculations clearly.
a marks Answer the following questions and elaborate on your answers.
i marks Assume that a relation is stored on disk consecutively, how many disk
seeks do we need if we read the entire relation, and read the relation from a certain
block, respectively?
ii marks Assume that relation INSTRUCTOR has a primary index A and a secondary
index B On what possible search keys are A and B built, respectively?
b marks Answer the following questions and show your calculations clearly.
i marks Consider the following SQL query:
select from COURSE where Name'Data Structure' Cid
Assume that relation COURSE has a Btree index of height on the Cid attribute.
Further assume that the Cid of COURSE are integers between to What are the
numbers of disk seeks and block transfers associated with the SQL query if we use
the Btree index? What are the numbers if we do not use the Btree index?
Should we use the Btree index? Explain briefly.
ii marks Consider the following SQL query:
select from INSTRUCTOR where Name 'Jack'
If we perform linear search, what are the numbers of disk seeks and block transfers
associated with the SQL query?
iii. marks Consider the following SQL query.
select from INSTRUCTOR where Id
Assume that the Id of relation INSTRUCTOR are integers between and Further
assume that INSTRUCTOR has a Btree index of height on the Id attribute. If we
use the Btree for the query, what are the numbers of disk seeks and block transfers
associated with the SQL query?
c marks Assume that relation INSTRCUTOR has a Btree index of height on the
DeptName attribute, and a Btree index of height on the Name attribute. Further
assume that there are instructors from the Computer Science Department.
i marks Is the tree on Name a primary or secondary index? Explain briefly.
ii marks Consider the following SQL query:
select from INSTRUCTOR where DeptName 'Computer Science'
If we use the tree on the DeptName attribute for the query, what are the numbers
of disk seeks and block transfers associated with the SQL query? The number of
accesses to the blocks that contain pointers to data records in the data file is ignored:
d marks Consider the following SQL query performing the join
operation:
select from INSTRUCTOR, TEACHES where
INSTRUCTOR.Id
TEACHES.Id
i marks Assume that blocks are allocated to the memory buffer. The query is
implemented by nestedloop join. Which of the relations should be the inner relation
that leads to a smaller number of seeks and block transfers? Explain your answer by
comparing the two cases with calculating the number of seeks and block transfers,
when different relations are chosen as the inner relation.
ii marks Assume that INSTRUCTOR has a Btree index of height on the Id
attribute. The query is implemented by indexed nestedloop join with TEACHES as
the outer relation. What are the numbers of disk seeks and block transfers?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
