GATE 2006 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2006

191 questions

MCQ 1911-mark 191

Questions 161–165 of 191

Q161Tuple Calculus1 markMCQ−0.33 if wrong
Which of the following relational query languages have the same expressive power?
I. Relational algebra
II. Tuple relational calculus restricted to safe expressions
III. Domain relational calculus restricted to safe expressions

Q162SQL1 markMCQ−0.33 if wrong
Consider a database with three relation instances shown below. The primary keys for the Drivers and Cars relation are did and cid respectively and the records are stored in ascending order of these primary keys as given in the tables. No indexing is available in the database.

diddnameratingage22Karthikeyan72529Salman13331Boris85532Amoldt82558Schumacher103564Sachin73571Senna101674Sachin93585Rahul32595Ralph353D: Drivers relationdidCidday2210110−10−062210210−10−062210308−10−062210407−10−063110210−11−163110306−11−163110412−11−166410105−09−066410208−09−067410308−09−06R: Reserves relation\overset{\text{D: Drivers relation}}{\begin{array}{|c|l|r|c|}\hline \textbf{did}& \textbf{dname}& \textbf{rating}& \textbf{age} \\\hline 22& \text{Karthikeyan}& 7& 25 \\ \hline 29& \text{Salman}& 1& 33 \\ \hline 31& \text{Boris}& 8& 55 \\\hline 32& \text{Amoldt}& 8& 25 \\\hline 58& \text{Schumacher}& 10& 35 \\\hline 64& \text{Sachin}& 7& 35 \\\hline 71& \text{Senna}& 10& 16 \\\hline 74& \text{Sachin}& 9& 35 \\\hline 85& \text{Rahul}& 3& 25 \\\hline 95& \text{Ralph}& 3& 53 \\\hline \end{array}} \qquad \overset{\text{R: Reserves relation}}{\begin{array}{|c|c|c|}\hline \textbf {did} & \textbf {Cid} & \textbf {day} \\\hline 22 & 101 & 10-10-06 \\ \hline 22 & 102 & 10-10-06\\ \hline 22 & 103 & 08-10-06 \\\hline 22 & 104 & 07-10-06 \\\hline 31 & 102 & 10-11-16 \\\hline 31&103 &06-11-16 \\\hline 31 & 104&12-11-16 \\\hline 64 & 101 &05-09-06 \\\hline 64& 102 & 08-09-06 \\\hline 74 & 103 & 08-09-06 \\\hline \end{array}}

CidCnamecolour101Renaultblue102Renaultred103Ferrarigreen104JaguarredC: Cars relation\overset{\text{C: Cars relation}}{\begin{array}{|c|c|c|c|}\hline \textbf {Cid} & \textbf {Cname} & \textbf{colour} \\\hline 101 & \text{Renault} & \text{blue} \\ \hline 102 & \text{Renault} & \text{red} \\ \hline 103 & \text{Ferrari} & \text{green} \\\hline 104 & \text{Jaguar} & \text{red} \\\hline \end{array}}
 
select D.dname
from Drivers D
where D.did in  (
                  select R.did
                  from Cars C, Reserves R
                  where R.cid = C.cid and C.colour = 'red'
                  intersect
                  select R.did
                  from Cars C, Reserves R
                  where R.cid  = C.cid and C.colour = 'green'
                  )

Let n be the number of comparisons performed when the above SQL query is optimally executed. If linear search is used to locate a tuple in a relation using primary key, then n lies in the range:

Q163SQL1 markMCQ−0.33 if wrong
Consider a database with three relation instances shown below. The primary keys for the Drivers and Cars relation are did and cid respectively and the records are stored in ascending order of these primary keys as given in the tables. No indexing is available in the database.

diddnameratingage22Karthikeyan72529Salman13331Boris85532Amoldt82558Schumacher103564Sachin73571Senna101674Sachin93585Rahul32595Ralph353D: Drivers relationdidCidday2210110−10−062210210−10−062210308−10−062210407−10−063110210−11−163110306−11−163110412−11−166410105−09−066410208−09−067410308−09−06R: Reserves relation\overset{\text{D: Drivers relation}}{\begin{array}{|c|l|r|c|}\hline \textbf{did}& \textbf{dname}& \textbf{rating}& \textbf{age} \\\hline 22& \text{Karthikeyan}& 7& 25 \\ \hline 29& \text{Salman}& 1& 33 \\ \hline 31& \text{Boris}& 8& 55 \\\hline 32& \text{Amoldt}& 8& 25 \\\hline 58& \text{Schumacher}& 10& 35 \\\hline 64& \text{Sachin}& 7& 35 \\\hline 71& \text{Senna}& 10& 16 \\\hline 74& \text{Sachin}& 9& 35 \\\hline 85& \text{Rahul}& 3& 25 \\\hline 95& \text{Ralph}& 3& 53 \\\hline \end{array}} \qquad \overset{\text{R: Reserves relation}}{\begin{array}{|c|c|c|}\hline \textbf {did} & \textbf {Cid} & \textbf {day} \\\hline 22 & 101 & 10-10-06 \\ \hline 22 & 102 & 10-10-06\\ \hline 22 & 103 & 08-10-06 \\\hline 22 & 104 & 07-10-06 \\\hline 31 & 102 & 10-11-16 \\\hline 31&103 &06-11-16 \\\hline 31 & 104&12-11-16 \\\hline 64 & 101 &05-09-06 \\\hline 64& 102 & 08-09-06 \\\hline 74 & 103 & 08-09-06 \\\hline \end{array}}

CidCnamecolour101Renaultblue102Renaultred103Ferrarigreen104JaguarredC: Cars relation\overset{\text{C: Cars relation}}{\begin{array}{|c|c|c|c|}\hline \textbf {Cid} & \textbf {Cname} & \textbf{colour} \\\hline 101 & \text{Renault} & \text{blue} \\ \hline 102 & \text{Renault} & \text{red} \\ \hline 103 & \text{Ferrari} & \text{green} \\\hline 104 & \text{Jaguar} & \text{red} \\\hline \end{array}}

What is the output of the following SQL query?
 
select D.dname
from Drivers D
where D.did in  (
                  select R.did
                  from Cars C, Reserves R
                  where R.cid = C.cid and C.colour = 'red'
                  intersect
                  select R.did
                  from Cars C, Reserves R
                  where R.cid  = C.cid and C.colour = 'green'
                   )

Q164SQL1 markMCQ−0.33 if wrong
Consider the relation enrolled (student, course) in which (student, course) is the primary key, and the relation paid (student, amount) where student is the primary key. Assume no null values and no foreign keys or integrity constraints. Given the following four queries:

Query 1: Select student from enrolled where student in (select student from paid)
Query 2: Select student from paid where student in (select student from enrolled)
Query 3: Select E.student from enrolled E, paid P where E.student = P.student
Query 4: Select student from paid where exists
(select * from enrolled where enrolled.student = paid.student)

Which one of the following statements is correct?

Q165SQL1 markMCQ−0.33 if wrong
Consider the relation account (customer, balance) where customer is a primary key and there are no mall values. We would like to rank customers according to decreasing balance. The customer with the largest balance gets rank 1. Ties are not broken but ranks are skipped: if exactly two customers have the largest balance they each get rank 1 and rank 2 is not assigned.
Query1:
select A.customer, count(B.customer)
from account A, account B
where A.balance <=B.balance
group by A.customer
Query2:
select A.customer, 1+count(B.customer)
from account A, account B
where A.balance < B.balance
group by A.customer

Consider these statements about Query 1 and Query 2.
1. Query 1will produce the same row set as Query 2 for some but not all databases
2. Both Query 1 Query 2 are correct implementations of the specification
3. Query 1 is a correct implementation of the specification but Query 2 is not
4. Neither query 1 nor Query 2 is a correct implementation of the specification
5. Assigning rank with a pure relational Query takes less time than scanning in decreasing balance order the assigning ranks using ODBC

Which two of the above statements are correct?