380 likes | 618 Views
CS3223 Tutorial 2. Fan Qi fan.qi@nus.edu.sg Database Lab 1, com1 #01-08. B+ Tree . Data Entry: Format 1: actual data record Format 2: key + RID Format 3: key, RID-List Properties & Attributes: Height Balanced Every node except root must be half full, [ d,2d]
E N D
CS3223 Tutorial 2 Fan Qi fan.qi@nus.edu.sg Database Lab 1, com1 #01-08
B+ Tree • Data Entry: • Format 1: actual data record • Format 2: key + RID • Format 3: key, RID-List • Properties & Attributes: • Height Balanced • Every node except root must be half full, [d,2d] • Fanout: # of pointers out of a non-leaf node
B+ Tree • Operations: • Search: • Insert: If siblings do not have space, split • Delete: If siblings are just of d, Merge, else borrow one (redistribution) Redistribution in insertion is not frequently used in practice
Question 1 g): Insert 59
Question 1 g): Insert 59
Question 1 g): Insert 59
Question 1 g): Insert 59
Question 1 g): Insert 59 Delete 91
Question 1 g): Insert 59 Delete 91
Question 1 g): Insert 59 Delete 91
Question 1 g): Insert 59 Delete 91 Underflow!
Question 1 g): Insert 59 Delete 91 Redistribution Failed Merge!
Question 1 g): Insert 59 Delete 91 Underflow again!
Question 1 g): Insert 59 Delete 91 Redistribution
Question 2 • Find level of tree:
Question 3 a): Get all records with key C A B
Question 3 a): Get all records with key C A B
Question 3 a): Get all records with key C A B
Question 3 a): Get all records with key C A B
Question 3 b): Insert a recode with key 109 C A B Split!!
Question 3 b): Insert a recode with key 109 C A B
Question 3 d):Which value would result Increasing in tree height? C A B 65-79, assume internal nodes do not re-distribute
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down Split
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down Split
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down Split
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down Split
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down Split
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Top-down Further Split
Question 4 11, 5, 3, 31,19,2,7,17,23,29,4,50,40,44 Bulk Loading Pros and Cons ?
Self Thinking Question • When data has duplication, how to handle it in B+ tree ? • Try to implement a B+ tree by yourself
Further Doubts? • TA Contact: • Fan Qi • fan.qi@nus.edu.sg • Database Lab 1, com1 #01-08 Happy Chinese New Year !