1
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
2
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
3
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6

A company maintains records of sales made by its salespersons and pays them commission based on each individual’s total sales made in a year. This data is maintained in a table with following schema:

salesinfo = (salespersonid, totalsales, commission)

In a certain year, due to better business results, the company decides to further reward its salespersons by enhancing the commission paid to them as per the following formula:

If commission < = 50000, enhance it by 2%
If 50000 < commission < = 100000, enhance it by 4%
If commission > 100000, enhance it by 6%

The IT staff has written three different SQL scripts to calculate enhancement for each slab, each of these scripts is to run as a separate transaction as follows:

T1: Update salesinfo
 Set commission = commission * 1.02
 Where commission < = 50000;

T2: Update salesinfo
 Set commission = commission * 1.04
 Where commission > 50000 and commission is < = 100000;

T3: Update salesinfo
 Set commission = commission * 1.06
 Where commission > 100000;
Which of the following options of running these transactions will update the commission of all salespersons correctly?
A
Execute T1 followed by T2 followed by T3
B
Execute T2, followed by T3; T1 running concurrently throughout
C
Execute T3 followed by T2; T1 running concurrently throughout
D
Execute T3 followed by T2 followed by T1
4
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
The relation book (title, price) contains the titles and prices of different books. Assuming that no two books have the same price, what does the following SQL query list?
Select title
 From book as B
 Where (select count(*)
   From book as T
   Where T.price > B.price) < 5;
A
Titles of the four most expensive books
B
Title of the fifth most inexpensive book
C
Title of the fifth most expensive book
D
Titles of the five most expensive books
GATE CSE Subjects
Software Engineering
Web Technologies
EXAM MAP
Medical
NEET
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
CBSE
Class 12