Index sequential files files that are ordered

Info icon This preview shows pages 38–40. Sign up to view the full content.

View Full Document Right Arrow Icon
Index-Sequential Files Files that are ordered sequentially on some search key and have a primary index on that search key are called index-sequential files . Contents of an index record / entry An index record or index entry consists of a search-key value and pointers to one or more records with that value as their search key value. The pointer to a record consists of the identifier of a disk block and an offset within the disk block to identify the record within the block. Types of ordered indices There are two types of ordered indices: Account_no Pointer A-1 A-2 A-3 A-4 A-5 A-6 A-7 A-8 A-9 A-10 Index file Account_no Branch_name Balance A-9 Adabor 300 A-1 Adabor 500 A-5 C. O. Bazar 560 A-8 Dhanmodi 590 A-3 Dhanmodi 420 A-2 Mirpur 600 A-4 Mirpur 520 A-10 Mirpur 120 A-6 Motijheel 600 A-7 Motijheel 200 Account file Figure: A secondary index. The Account file is ordered according to Branch_name . But the index file is ordered according to Account_no . Branch_name Pointer Adabor C.O. Dhanmondi Mirpur Motijheel Index file Account_no Branch_name Balance A-9 Adabor 300 A-1 Adabor 500 A-5 C. O. Bazar 560 A-8 Dhanmodi 590 A-3 Dhanmodi 420 A-2 Mirpur 600 A-4 Mirpur 520 A-10 Mirpur 120 A-6 Motijheel 600 A-7 Motijheel 200 Account file Figure: A primary index. The Account file is ordered according to Branch_name (which is not a primary key). The index file is also ordered according to Branch_name .
Image of page 38

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
35 1. Dense Index 2. Sparse Index Dense Index Dense index is the index where an index record appears for every search-key value in the file. Dense index for primary indices In a dense primary index, the index record contains the search-key value and a pointer to the first data record with that search-key value. The rest of the records with the same search key-value would be stored sequentially after the first record, since, because the index is a primary one, records are sorted on the same search key. Another implementation of dense indices A dense index can also be implemented by storing a list of pointers to all records with the same search- key value. Doing so is not essential for primary indices. Sparse Index Sparce index is the index where an index record appears for only some of the search-key values in the file. As is true in dense indices, each index record contains a search-key value and a pointer to the first data record with that search-key value. To locate a record, we find the index entry with the largest search-key value that is less than or equal to the search-key value for which we are looking. We start at the record pointed to by that index entry, and follow the pointers in the file until we find the desired record. Figure: Another implementation of dense index. Branch_name Pointer Adabor C.O. Dhanmondi Mirpur Motijheel Index file Account_no Branch_name Balance A-9 Adabor 300 A-1 Adabor 500 A-5 C. O. Bazar 560 A-8 Dhanmodi 590 A-3 Dhanmodi 420 A-2 Mirpur 600 A-4 Mirpur 520 A-10 Mirpur 120 A-6 Motijheel 600 A-7 Motijheel 200 Account file Figure: Dense index for a primary index.
Image of page 39
Image of page 40
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern