search
Log In
3 votes
406 views

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 08/10/06
22 104 07/10/06
31 102 10/11/06
31 103 06/11/06
31 104 12/11/06
64 101 05/09/06
64 102 08/09/06
74 103 08/09/06
      C: cars relation
cid cname colour
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.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 Binary Search is used to locate a tuple in a relation using primary key, then what is the range of n?

in Databases 406 views
0
Does this query print Karthikeyan   Boris?
0
yes.

Please log in or register to answer this question.

Related questions

0 votes
0 answers
1
173 views
Student table ROLLNO NAME MARKS1 MARKS2 1 T 50 30 2 S 70 99 3 D NULL 10 NULL NULL 78 NULL NULL NULL NULL NULL a) select count(MARKS1) from student; b) select count(*) from student;
asked Dec 15, 2017 in Databases Tuhin Dutta 173 views
1 vote
3 answers
2
315 views
Class(name, meets_at, room, fid) Faculty(fid, fname, deptid) Find the names of faculty members who teach in every room in which some class is taught
asked May 18, 2019 in Databases aditi19 315 views
0 votes
0 answers
3
264 views
Product(maker, model, type) PC(model, speed, ram, hd, price) Laptop(model, speed, ram, hd, screen, price) Printer(model, color, type, price) Find the maker(s) of the PC(s) with the fastest processor among all those PC 's that have the smallest amount of RAM pls check if my SQL ... p.model from PC p where p.speed IN( select max(p1.speed) from PC p1 where p1.ram IN( select MIN(p2.ram) from PC p2)))
asked May 8, 2019 in Databases aditi19 264 views
0 votes
0 answers
4
192 views
I got why query 2 is wrong. How do I approach to understand Query 1, is there a generic approach for solving questions like these which have no tables given?
asked Jan 8, 2019 in Databases amitqy 192 views
...