in Databases recategorized by
2,025 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
in Databases recategorized by
by
2.0k views

1 comment

@MiNiPanda explain this one

0
0

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 vote
1 vote

answer is C

3 Comments

means it could be anything

even B tree can do this
0
0
what's the use of such Answers ?
1
1
exactly @aakashpreetam
0
0
1 vote
1 vote

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