Slide 13.12: File operations for secondary indexes
Slide 13.14: Improving the secondary index structures
Home

Retrieval Using Combinations of Secondary Keys


The most important use of secondary keys is combining them to retrieve a subset of records from the data file. For example, we can use combinations of secondary keys and boolean operations AND/OR to specify the intersection/union of two subsets of the data file. Consider the following query:

Question: Find all data records with:
Composer = “BEETHOVEN” AND 
   Title = “SYMPHONY NO.9”
ANG3795
DG139201
DG18807
RCA2626
  First the composer index is searched for the list of Label IDs that identify records with BEETHOVEN as composer.

Next the title index is searched for the Label IDs associated with records that have SYMPHONY NO. 9 as title.  
ANG3795
COL31809
DG18807

ANG3795
DG18807
  Now the boolean AND is performed and only the Label IDs that appear in both lists are considered.

Finally, once we have the list of primary keys occurring in both lists, we can proceed to the primary key index to look up the addresses of the data file records. Then we can retrieve the records:

ANG 3795 Symphony No. 9 Beethoven Guilini
DG 18807 Symphony No. 9 Beethoven Karajan