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?