in Databases edited by
9,772 views
47 votes
47 votes

There are five records in a database.
$$\begin{array}{|c|c|c|c|} \hline \textbf {Name} & \textbf {Age} & \textbf {Occupation} &  \textbf{Category } \\\hline \text{Rama} & \text{27} & \text{CON} & \text{A} \\\hline \text{Abdul} & \text{22} & \text{ENG} & \text{A} \\\hline \text{Jennifer} & \text{28} & \text{DOC} & \text{B} \\\hline \text{Maya} & \text{32} & \text{SER} & \text{D} \\\hline \text{Dev} & \text{24} & \text{MUS} & \text{C} \\\hline \end{array}$$

There is an index file associated with this and it contains the values $1, 3, 2, 5$ and $4$. Which one of the fields is the index built from?

  1. Age
  2. Name
  3. Occupation
  4. Category
in Databases edited by
9.8k views

1 comment

  • What if there was some field in the table given above, whose values were in-fact 1,3,2,5 and 4 ?
  •  In the question - "Index file associated with this and it contains the values 1,3,2,5 and 4." Are these "values" the record pointers ? (I am assuming as such).
1
1

2 Answers

77 votes
77 votes
Best answer
Indexing will be on Occupation field because Occupation field lexicographically sorted will give the sequence $1,3,2,5,4$.

Correct Answer: $C$
edited by

3 Comments

edited by
The ordering of index records if Occupation attribute is choosed.

['CON' (1) , 'DOC' (2) , 'ENG'(3) , 'MUS' (4) , 'SER'(5)]

For other fields ,

Age is choosen,

22 gets index value 1, but from the given database 27 should get, hence not for Age Attribute.

Similar reason for Name attribute.

Category attribute is not as it contains duplicate values.

Hence correct answer is Occupation.
18
18

@Digvijay Pandey

Sir, what if all attributes having some duplicates values then index number(block anchor) should be count duplicate as 1 and then ordered attribute would be selected for block anchor ?

0
0

Consider Occupation Field, Sort it in dictionary order.

We get: C,D,E,M,S:{1,2,3,4,5} Once sequence numbers are assigned, index is prepared as.

Index No. Sequence No
1 1(CON)
2 3(ENG)
3 2(DOC)
4 5(SER)
5 4(MUS)

Index records are always sorted by Index No.

 

3
3
7 votes
7 votes
No Matter whether any Field Of Data File Is Sorted OR Not , INDEX IS ALWAYS SORTED.

Means For 5 Rows Index Key Value will be 1,2,3,4,5 .

Now depending On Which Field (Column) we need to perform indexing on , the block ptr will point to that

So u should Search For A Field Where Ascending Order Is 1,3,2,5,4.

So Basically Keys(1,2,3,4,5) will be associated with (1,3,2,5,4) which matches with lexicographic order in "Occupation".

                                                                                   (C,D,E,M,S)
Answer:

Related questions