Improving the Phone Book Application II

Let’s learn about the enhancements to improve the functionality and usability of the phone book application.

Adding an index

Let’s first discuss how the database index is implemented with the help of a map. Indexing in databases is based on one or more keys that are unique. In practice, we index something that is unique and that we want to access quickly. In the database case, primary keys are unique by default and can’t be present in more than one record. In our case, phone numbers are used as primary keys, which means that the index is built based on the phone number field of the structure.

Note: As a general rule, we index a field that is going to be used for searching. There is no point in creating an index that is not going to be used for querying.

Working on an index

Let’s now see what this means in practice. Imagine that we have a slice named S with the following kind of data:

Get hands-on with 1400+ tech skills courses.