Lecture 10. Indexing and Hashing

Indexing and Hashing

顺序索引:基于值的顺序排序
散列索引:基于将值平均分布到若干散列桶中

聚集索引(clustering index)or 主索引(primary index):如果包含记录的文件按照某个搜索码指定的顺序排序,那么该搜索码对应的索引称为聚集索引。聚集索引的搜索码常常是主码,尽管并非必须如此。
非聚集索引(nonclustering index)or 辅助索引(secondary index):搜索码指定的顺序与文件中记录的物理顺序不同的索引称为非聚集索引

稠密索引(dense index):在稠密索引中,文件中的每个搜索码值都有一个索引项。在稠密非聚集索引中,索引必须存储指向所有具有相同搜索码值的记录的指针列表。
稀疏索引(sparse index):在稀硫索引中,只为搜索码的某些值建立索引项,只有索引是聚集索引时才能使用稀疏索引

B+树

叶结点最多有 n − 1 n-1 n1 个值,最少有 ⌈ ( n − 1 ) / 2 ⌉ \lceil (n-1)/2\rceil (n1)/2 个值
非叶节点最多可容纳 n n n 个指针,最少必须有 ⌈ n / 2 ⌉ \lceil n/2\rceil n/2 个指针

insertion
在这里插入图片描述
insert “Adams”:
在这里插入图片描述
insert “Lamport”:
在这里插入图片描述

Deletion
在这里插入图片描述
delete “Srinivasan”:
在这里插入图片描述
delete “Singh” and “Wu”:
在这里插入图片描述
delete “Gold”:
在这里插入图片描述

B树

Similar to B+tree, but B-tree allows search-key values to appear only once; eliminates redundant storage of search keys.
在这里插入图片描述

  • Advantages of B-Tree indices:
    ➢ May use less tree nodes than a corresponding B+tree (because of duplicate).
    ➢ Sometimes possible to find search-key value before reaching leaf node.
  • Disadvantages of B-Tree indices:
    ➢ Only small fraction of all search-key values are found early
    ➢ Non-leaf nodes are larger, so fan-out is reduced. Thus B-Trees typically have greater depth than corresponding B+Tree
    ➢ Insertion and deletion more complicated than in B+Trees
    ➢ Implementation is harder than B+Trees.
    因而许多数据库实现使用B+树
Hash

bucket overflow(桶溢出)处理:

  • close addressing:增加溢出桶、溢出链,用来存储溢出部分
  • open addressing:溢出部分放到别的桶中(无溢出链)

Dynamic Hashing 动态散列

extendable hashing 可扩充散列
https://www.cnblogs.com/kegeyang/archive/2012/04/05/2432608.html

Index Definition in SQL
create index <index-name> on <table-name> (<attribute-list>)
create unique index uni-acnt-index on account(account- number)
drop index <index-name>

Bitmap Indices

https://blog.csdn.net/hellojoy/article/details/81740997

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值