advanced database discussion n.
Skip this Video
Loading SlideShow in 5 Seconds..
Advanced Database Discussion PowerPoint Presentation
Download Presentation
Advanced Database Discussion

Loading in 2 Seconds...

play fullscreen
1 / 33

Advanced Database Discussion - PowerPoint PPT Presentation

  • Uploaded on

Advanced Database Discussion. B+ Tree. Outlines. B+ Tree Definition B+ Tree Properties B+ Tree Searching B+ Tree Insertion B+ Tree Deletion. B+ Tree The Most Widely Used Index. B+Tree is The super index structure for disk-based databases

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

Advanced Database Discussion

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. Advanced Database Discussion B+ Tree

    2. Outlines • B+ Tree Definition • B+ Tree Properties • B+ Tree Searching • B+ Tree Insertion • B+ Tree Deletion

    3. B+ TreeThe Most Widely Used Index • 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).

    4. B+ Tree Construction • 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

    5. Difference between B-tree and B+-tree • 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

    6. Fill Factor • 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:

    7. B+ TreeThe Most Widely Used Index • Main characteristics: • Insert/delete at logFoN cost; keep tree height-balanced. (Fo = fanout, N = # leaf pages) • Minimum 50% occupancy (except for root). Each node contains d <= m <= 2d entries. The parameter d is called the order of the tree. • Supports equality and range-searches efficiently.

    8. B+ Tree Properties

    9. B+ Tree Searching

    10. B+ Tree Searching

    11. Example B+ Tree • 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!

    12. Inserting a Data Entry into B+Tree • 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.

    13. B+ Tree Insertion

    14. B+ Tree Insertion

    15. B+ Tree Construction

    16. B+ Tree Construction

    17. B+ Tree Construction

    18. Examples of Insertion in B+ Tree Internal (push)

    19. 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.

    20. 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

    21. Redistribution with sibling nodes • 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.

    22. Deleting a Data Entry from a B+ Tree • 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.

    23. B+ Tree Deletion

    24. B+ Tree Deletion

    25. Examples of Deletion from B+ Tree

    26. Examples of Deletion from B+ Tree

    27. Examples of Deletion from B+ Tree

    28. 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 B Trees & B+ Trees

    29. Concluding Remarks • 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