What are some problems with hash tables

The hash table - fast database access to hash values

For Databases hash tables are used to perform searches and to enter or delete data records accelerate. For example, searching a database of all employees in a company for a surname can take a long time because each database field is searched for a match one after the other (sequentially). If you convert the search term into a hash value and use it to search for a match in the hash table, it is usually much faster.

How is this implemented? Everyone record gets one unique address. The type of addressing is always identical within the database (001, 002, 003 or 00A1, 00A2, 00A3 etc.). This address is calculated using the hash function.

An easy example: A database has space for 11 entries, from position 0 to position 10. The name "Lisa" consists of four ASCII characters with the respective ASCII codes: L is 76, i is 105, s is 115 and a is 97. You can try this out for yourself in Windows using the number field: [Alt] + 0076, for example, results in "L". All ASCII values ​​are added and result in hash value 393 for "Lisa". The addition of the ASCII values ​​now corresponds to a hash function.

Then one will Residual value calculation with integers executed: 393% 11 (memory locations) = 35, remainder 8 (the percentage sign "%" is the mathematical operator for calculating the remainder in many programming languages). This residual value now determines where in the database - here in the calculation example the Index number 8 - Lisa and all other information about her are saved. It is easy to imagine that with this type of addressing, the same residual values ​​often occur. However, the more storage spaces and the longer the hash value used, the lower the probability that such a duplication will occur. In the case of “Alis Meyer”, despite the “identical” letters, a completely different positioning would occur, as the “A” is now uppercase and the “l” is now lowercase.