-4

My question is that whether Dense and Sparse indexes are primary or secondary? How can I identify any index whether its primary or secondary?

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
abdul rafay
  • 143
  • 1
  • 8
  • What do you mean with primary/secondary index? Please try to better explain your question. Which DBMS? – Aleksej Jul 29 '16 at 10:18

3 Answers3

3

In RDBMS, primary index can be dense or sparse. That is depend on you requirement.

Primary index: in a sequentially ordered file, the index whose search key specifies the sequential order of the file

Secondary index: an index whose search key specifies an order different from the sequential order of the file.

Dense index: Index record appears for every search-key value in the file.

Sparse Index: contains index records for only some search-key values.

For Sparse index, a good tradeoff would be keeping an index entry for every block in file. When we are reading an entry from the storage, we take the entire block and go through it. We can skip the mappings that are included in that block.

For Primary index, we can have a dense or sparse index.

But for secondary index, it is essential to have dense index as the data entries are not in a sequential order for the secondary index. Main point of keeping a sparse index is that we should be able to find out the other search keys with the help of it. That can only be achieved if the files are in order. That's why we need an index mapping for every search key in secondary index which is dense index.

Lakshitha
  • 1,021
  • 1
  • 6
  • 15
1

Primary index is unique, secondary index don't have to be unique.

Sparse index don't store every possible value, Dense index does store every possible value.

So a primary index has to be dense to work, a secondary index can be either dense or sparse depending on need. A dense index is using more space to store data, while a sparse index is slower.

A similar question is answered here

Community
  • 1
  • 1
Linkan
  • 581
  • 1
  • 7
  • 18
-1

Primary index are unique because the search is contained primarily and non duplicate .so it is a dense .while secondary is not unique because the search key is contained secondarily and duplicate so it is usually sparse but may be dense in case of incasity

George
  • 1
  • 1