849 views
3 votes
3 votes

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?

Please log in or register to answer this question.

Related questions

0 votes
0 votes
0 answers
1
Tuhin Dutta asked Dec 15, 2017
413 views
Student tableROLLNONAMEMARKS1MARKS21T50302S70993DNULL10NULLNULL78NULLNULLNULLNULLNULLa) select count(MARKS1) from student;b) select count(*) from student;
0 votes
0 votes
1 answer
3
rayhanrjt asked Jan 6, 2023
791 views
Write SQL command to find DepartmentID, EmployeeName from Employee table whose average salary is above 20000.
2 votes
2 votes
1 answer
4
Subhrangsu asked Jun 18, 2022
453 views
Write SQL query to show all employees hired on June 4,1984 (non-default format)emp(empno,ename,job,mgr,hiredate,sal,comm,deptno)