recategorized by
2,057 views
3 votes
3 votes

Consider the following query :

$SELECT$ E.eno, $COUNT(*)$
$FROM$ Employees E
$GROUP\, BY$ E.eno

If an index on $eno$ is available, the query can be answered by scanning only the index if

  1. the index is only hash and clustered 
  2. the index is only $B+$ tree and clustered 
  3. index can be hash or $B+$ tree and clustered or non-clustered 
  4. index can be hash or $B+$ tree and clustered
recategorized by

3 Answers

3 votes
3 votes
By hashing and chaining technique , we can group the index w.r.t primary keys

In clustering index we can group ordering field with a non key value(Note:One file can have one primary index or one clustering index, but not both)

In non clustering or secondary index  can be specified for any non ordering field of a file

$B^{+}$ tree work on non key field too, where grouping has been done with the branching of tree
1 votes
1 votes

answer is C

1 votes
1 votes

Let's compare these indexing techniques.

Hash Tables B Trees

Not suitable for range queries, since they don't keep keys in any order.

So, only suitable for "=" queries (or point queries)

Suitable for range queries, since the keys are kept in order.

So, suitable for  =, >, >=, <, <=, or BETWEEN operators (range queries)

Not Scalable Scalable
More suitable for primary key based lookups. Also suitable for primary key based lookups, but Hash Tables are better because of their Time Complexity.
O(1) performance if the hash function is chosen wisely,and Hash Table is sufficiently large.
Otherwise degrades to O(n).
Always O(logn) performance.

Sources: This, this and this.



 the query can be answered by scanning only the index if

We just have to scan the index, not the Database file. Hash Table with Chaining, and B+ trees are fine.

Now, we have to output the row count of a specific eno. This can be done by looking at any index.

We aren't asked which will be faster; we're asked if it can be answered. Nor is it given that the query is a range query.

 the query can be answered by scanning only the index if

So, Option C

Answer:

Related questions

5 votes
5 votes
2 answers
3
gatecse asked Dec 17, 2017
2,784 views
Consider the following schema:$\text{Sailors(sid,sname,rating,age)}$$\text{Boats(bid,bname,colour)}$$\text{Reserves(sid,bid,day)}$Two boats can have the same name but the...