📜  DBMS 中索引和散列的区别

📅  最后修改于: 2021-09-12 10:50:27             🧑  作者: Mango

1.索引
顾名思义,索引是一种通常用于加速数据访问的技术或机制。索引基本上是一种数据结构,用于快速定位和访问数据库表中的数据。使用一列或多列数据库表可以轻松开发或创建索引。

2.哈希
哈希,顾名思义,是一种技术或机制,它使用哈希函数和搜索关键字作为参数来生成数据记录的地址。它在不使用索引结构的情况下计算数据记录在磁盘上的直接位置。一个好的散列函数只使用单向散列算法,散列不能转换回原始密钥。简而言之,它是将给定的键转换为另一个值的过程,称为哈希值或简称为哈希。

DBMS 中索引和散列的区别:

Indexing  

Hashing  

It is a technique that allows to quickly retrieve records from database file. It is a technique that allows to search location of desired data on disk without using index structure.  
It is generally used to optimize or increase performance of database simply by minimizing number of disk accesses that are required when a query is processed.  It is generally used to index and retrieve items in database as it is faster to search that specific item using shorter hashed key rather than using its original value.  
It offers faster search and retrieval of data to users, helps to reduce table space, makes it possible to quickly retrieve or fetch data, can be used for sorting, etc.   It is faster than searching arrays and lists, provides more flexible and reliable method of data retrieval rather than any other data structure, can be used for comparing two files for quality, etc.  
Its main purpose is to provide basis for both rapid random lookups and efficient access of ordered records.  Its main purpose is to use math problem to organize data into easily searchable buckets.  
It is not considered best for large databases and its good for small databases.   It is considered best for large databases. 
Types of indexing includes ordered indexing, primary indexing, secondary indexing, clustered indexing. Types of hashing includes static and dynamic hashing.  
It uses data reference to hold address of disk block.  It uses mathematical functions known as hash function to calculate direct location of records on disk.  
It is important because it protects file and documents of large size business organizations, and optimize performance of database. It is important because it ensures data integrity of files and messages, takes variable length string or messages and compresses and converts it into fixed length value.