In the database tables are used hash to speed up the search process, registration and deletion of data sets. Let's imagine that a last name is searched in a database that includes all the workers of a company: the task can take a long time because, in a conventional way, each of the fields in the database is searched for a match, one after another (sequentially). If, however, the search term becomes a value hash and then look at the table hash , the process usually take much less time.
How exactly is this done? Each data set is assigned a unique address . The rules that govern this assignment are always the same within each database (001, 002, 003 or 00A1, 00A2, 00A3, etc.). The address is calculated using the hash function .
As a simple example , let's say we have a database with space for 11 entries, in positions 0 to 10. The name Lisa is made up of 4 ASCII characters, each with an ASCII code: L is 76, i is 105, s is 115 and a is 97. You can check this assignment yourself using the numeric keypad: you will see that with [Alt] + 0076, for example, an L is displayed . Then all the ASCII values of Lisa are added , resulting in hash value 393. In this case, the sum of the ASCII values corresponds to a hash function .
This is followed by a calculation of the remainder with integers : 393% 11 (entries that fit in the base) = 35, remainder 8 (in many programming languages the percentage symbol % corresponds to the mathematical operator of the calculation of the remainder). This remainder will determine where in the database (in our example calculation, index number 8 ) Lisa and all the data related to her will be stored . As you may have already guessed, in this type of addressing, the resulting residuals are often repeated. The more storage space and the longer the hash value used, the lower the probability that such repetitions will occur. In the case of the name Alis , even if the letters of the name match those of Lisa, the positioning would be different, since A is uppercase and L is lowercase.