1
GATE CSE 2006
MCQ (Single Correct Answer)
+2
-0.6
Consider the relation account (customer, balance) where customer is a primary key and there are no null values. We would like to rank customers according to decreasing balance. The customer with the largest balance gets rank 1. Ties are not broke 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 Query1 and Query2.

1. Query1 will produce the same row set as Query2 for some but not all databases.

2. Both Query1 and Query2 are correct implementation of the specification

3. Query1 is a correct implementation of the specification but Query2 is not

4. Neither Query1 nor Query2 is a correct implementation of the specification

5. Assigning rank with a pure relational query takes less time than scanning in decreasing balance order assigning ranks using ODBC.

Which two of the above statements are correct?

A
2 and 5
B
1 and 3
C
1 and 4
D
3 and 5
2
GATE CSE 2006
MCQ (Single Correct Answer)
+2
-0.6

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?

A
All queries return identical row sets for any database
B
Query 2 and Query 4 return identical row sets for all databases but there exist databases for which Query 1 and Query 2 return different row sets.
C
There exist databases for which Query 3 returns strictly fewer rows than Query 2
D
There exist databases for which Query 4 will encounter an integrity violation at runtime.
3
GATE CSE 2006
MCQ (Single Correct Answer)
+2
-0.6

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.

D: Drivers Relation

Did Dname rating Age
22 Karthikeyan 7 25
29 Salman 1 33
31 Boris 8 55
32 Amoldt 8 25
58 Schumacher 10 35
64 Sachin 7 35
71 Senna 10 16
74 Sachin 9 35
85 Rahul 3 25
95 Ralph 3 53

R: Reserves Relation

Did cid Day
22 101 10/10/06
22 102 10/10/06
22 103 8/10/06
22 104 7/10/06
31 102 10/11/06
31 103 6/11/06
31 104 12/11/06
64 101 5/9/06
64 102 8/9/06
74 103 8/9/06

C: Cars relation

cid Cname Color
101 Renault
Blue
102 Renault
Red
103 Ferrari Green
104 Jaguar Red
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.color = '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

A
36 - 40
B
44 - 48
C
60 - 64
D
100 - 104
4
GATE CSE 2006
MCQ (Single Correct Answer)
+2
-0.6

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.

D: Drivers Relation

Did Dname rating Age
22 Karthikeyan 7 25
29 Salman 1 33
31 Boris 8 55
32 Amoldt 8 25
58 Schumacher 10 35
64 Sachin 7 35
71 Senna 10 16
74 Sachin 9 35
85 Rahul 3 25
95 Ralph 3 53

R: Reserves Relation

Did cid Day
22 101 10/10/06
22 102 10/10/06
22 103 8/10/06
22 104 7/10/06
31 102 10/11/06
31 103 6/11/06
31 104 12/11/06
64 101 5/9/06
64 102 8/9/06
74 103 8/9/06

C: Cars relation

cid Cname Color
101 Renault
Blue
102 Renault
Red
103 Ferrari Green
104 Jaguar Red

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.color = 'green')
A
Karthikeyan, Boris
B
Sachin, Salman
C
Karthikeyan, Boris, Sachin
D
Schumacher, Seena
EXAM MAP
Medical
NEET
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
CBSE
Class 12