1.05k likes | 1.18k Views
CPS216: Advanced Database Systems. Notes 05: Operators for Data Access (contd.) Shivnath Babu. Insertion in a B-Tree. n = 2. 49. 36. 49. 15. Insert: 62. Insertion in a B-Tree. n = 2. 49. 36. 49. 62. 15. Insert: 62. Insertion in a B-Tree. n = 2. 49. 36. 49. 62. 15.
E N D
CPS216: Advanced Database Systems Notes 05: Operators for Data Access (contd.) Shivnath Babu
Insertion in a B-Tree n = 2 49 36 49 15 Insert: 62
Insertion in a B-Tree n = 2 49 36 49 62 15 Insert: 62
Insertion in a B-Tree n = 2 49 36 49 62 15 Insert: 50
Insertion in a B-Tree n = 2 49 62 36 49 50 62 15 Insert: 50
Insertion in a B-Tree n = 2 49 62 36 49 50 62 15 Insert: 75
Insertion in a B-Tree n = 2 49 62 36 49 50 62 75 15 Insert: 75
Insertion: Primitives • Inserting into a leaf node • Splitting a leaf node • Splitting an internal node • Splitting root node
Inserting into a Leaf Node 58 54 57 60 62
Inserting into a Leaf Node 58 54 57 60 62
Inserting into a Leaf Node 58 54 57 58 60 62
Splitting a Leaf Node 61 54 66 54 57 58 60 62
Splitting a Leaf Node 61 54 66 54 57 58 60 62
Splitting a Leaf Node 61 54 66 54 57 58 60 61 62
Splitting a Leaf Node 59 61 54 66 54 57 58 60 61 62
Splitting a Leaf Node 61 54 59 66 54 57 58 60 61 62
Splitting an Internal Node … 21 99 … 59 40 54 66 74 84 [54, 59) [ 59, 66) [66,74)
Splitting an Internal Node … 21 99 … 59 40 54 66 74 84 [54, 59) [ 59, 66) [66,74)
Splitting an Internal Node 66 … 21 99 … [66, 99) [21,66) 40 54 59 74 84 [54, 59) [ 59, 66) [66,74)
Splitting the Root 59 40 54 66 74 84 [54, 59) [ 59, 66) [66,74)
Splitting the Root 59 40 54 66 74 84 [54, 59) [ 59, 66) [66,74)
Splitting the Root 66 40 54 59 74 84 [54, 59) [ 59, 66) [66,74)
Deletion redistribute
Deletion - II merge
Deletion - II Not needed merge
Deletion: Primitives • Delete key from a leaf • Redistribute keys between sibling leaves • Merge a leaf into its sibling • Redistribute keys between two sibling internal nodes • Merge an internal node into its sibling
Merge Leaf into Sibling 72 … 85 67 54 58 64 68 72 75
Merge Leaf into Sibling 72 … 85 67 54 58 64 68 75
Merge Leaf into Sibling 72 … 85 67 54 58 64 68 75
Merge Leaf into Sibling 72 … 85 54 58 64 68 75
Merge Internal Node into Sibling … 59 … 41 63 74 48 52 [52, 59) [59,63)
Merge Internal Node into Sibling … 59 … 41 48 52 59 63 [52, 59) [59,63)