Download - Advanced Database Discussion
![Page 1: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/1.jpg)
![Page 2: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/2.jpg)
B+ Tree Definition B+ Tree Properties B+ Tree Searching B+ Tree Insertion B+ Tree Deletion
![Page 3: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/3.jpg)
B+Tree is The super index structure for disk-based databases
The B+ Tree index structure is the most widely used of several index structures that maintain their efficiency despite insertion and deletion of data.
Leaf pages are not allocated sequentially. They are linked together through pointers (a doubly linked list).
![Page 4: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/4.jpg)
B+-Tree uses different nodes for leaf nodes and internal nodes› Internal Nodes: Only unique keys and
node links No data pointers!
› Leaf Nodes: Replicated keys with data pointer Data pointers only here
![Page 5: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/5.jpg)
In a B-tree, pointers to data records exist at all levels of the tree
In a B+-tree, all pointers to data records exists at the leaf-level nodes
A B+-tree can have less levels (or higher capacity of search values) than the corresponding B-tree
The B+-Tree is an optimization of the B-Tree› Improved traversal performance› Increased search efficiency› Increased memory efficiency
![Page 6: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/6.jpg)
B+ Trees use a “fill factor” to control the growth and the shrinkage.
50% fill factor is the minimum for a B+ Tree.
For n=4, the following guidelines must be met:
Number of Number of Keys/PageKeys/Page
44
Number of Number of Pointers/PagePointers/Page
55
Fill FactorFill Factor50%50%
Minimum Keys Minimum Keys in each pagein each page
22
![Page 7: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/7.jpg)
![Page 8: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/8.jpg)
![Page 9: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/9.jpg)
![Page 10: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/10.jpg)
![Page 11: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/11.jpg)
Search begins at root, and key comparisons direct it to a leaf. At each node, a binary search or linear search can be performed
Search for 5*, 15*, all data entries >= 24*
• Based on the search for 15*, we know it is not in the tree!
![Page 12: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/12.jpg)
Find correct leaf L. Put data entry onto L.
› If L has enough space, done!› Else, must split L (into L and a new node L2)
Redistribute entries evenly, copy up middle key. Insert index entry pointing to L2 into parent of L.
This can happen recursively› To split index node, redistribute entries evenly,
but push up middle key. (Contrast with leaf splits.)
Splits “grow” tree; root split increases height.› Tree growth: gets wider or one level taller at top.
![Page 13: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/13.jpg)
![Page 14: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/14.jpg)
![Page 15: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/15.jpg)
![Page 16: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/16.jpg)
![Page 17: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/17.jpg)
![Page 18: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/18.jpg)
Internal
(push)
![Page 19: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/19.jpg)
![Page 20: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/20.jpg)
Notice that root was split, leading to increase in height.
In this example, we can avoid split by re-distributing entries; however, this is usually not done in practice.
![Page 21: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/21.jpg)
Notice that the value 5 occurs redundantly, once in a leaf page and once in a non-leaf page. This is because values in the leaf page cannot be pushed up, unlike the value 17
![Page 22: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/22.jpg)
If a leaf node where insertion is to occur is full, fetch a neighbour node (left or right).
If neighbour node has space and same parent as full node, redistribute entries and adjust parent nodes accordingly
Otherwise, if neighbour nodes are full or have a different parent (i.e., not a sibling), then split as before.
![Page 23: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/23.jpg)
![Page 24: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/24.jpg)
Start at root, find leaf L where entry belongs.
Remove the entry.› If L is at least half-full, done!› If L has only d-1 entries,
Try to re-distribute, borrowing from sibling (adjacent node with same parent as L).
If re-distribution fails, merge L and sibling. If merge occurred, must delete entry
(pointing to L or sibling) from parent of L. Merge could propagate to root, decreasing
height.
![Page 25: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/25.jpg)
![Page 26: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/26.jpg)
![Page 27: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/27.jpg)
![Page 28: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/28.jpg)
![Page 29: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/29.jpg)
![Page 30: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/30.jpg)
![Page 31: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/31.jpg)
![Page 32: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/32.jpg)
B Trees: Multi-way trees Dynamic growth Contains only data
pages
B+ Trees: Contains features
from B Trees Contains index and
data pages Dynamic growth
![Page 33: Advanced Database Discussion](https://reader038.vdocuments.site/reader038/viewer/2022110211/56813329550346895d9a188c/html5/thumbnails/33.jpg)
Tree structured indexes are ideal for range-searches, also good for equality searches
B+ Tree is a dynamic structure› Insertions and deletions leave tree height
balanced› High fanout means depth usually just 3 or
4› Almost always better than maintaining a
sorted file