When a new record is inserted into the file, the DBMS must modify the indexes for each secondary-key field. For nonunique keys, it must make sure that the new record key value is in the values table; if it is, it adds the new record address to the appropriate entry in the occurrence table. If it is not, it must insert new entries in the values and occurrence tables. When a record is deleted, its address must be removed from the occurrence table. If no addresses remain in the occurrence table entry, the corresponding val-ues table entry must also be deleted.
When the secondary-key field of a record is modified, the record address must be removed from one occurrence table entry and inserted into another. If the modification is a new value for the key, an entry must be added to the values table.
The index approach to representing secondary keys overcomes the objections to the linked-list ap-proach. Direct processing of sets is possible. For example, the third record in a set can be retrieved without processing the first or second one. Also, it is possible to dynamically create and delete second-ary keys. No changes are made in the records themselves; the DBMS merely creates additional values and occurrence tables. Finally, unique keys can be processed efficiently.
The disadvantages of the index approach are that it requires more file space (the tables use more over-head than the pointers do) and that the DBMS programming task is more complex.
Note that the application programming task is not necessarily any more or less difficult—but it is more complex to write DBMS software that processes indexes than it is to write software that processes linked lists. Finally, modifications are usually processed more slowly because of the reading and writing actions required to access and maintain the values in the occurrence tables.