Index Structure for Files
Secondary Global Allocation Map Index Allocation Map (IAM) for table 1 Headers PFS Page Free space GAM Global Allocation Map SGAM Secondary Global Allocation Map Start of table 1 Index Allocation Map (IAM) for table 2 Start of table 2 Index Allocation Map (IAM) for index 90 Start of index 90
Cash 1 2 Write-ahead Log 3 4 5 6 Flushing Database T1 x 5 89 T1 y 15 9 T3 w 75 500 …………….. …………….. …………….. …………….. Clean Pages …………….. …………….. …………….. …………….. …………….. Check Point MinLSN Flushing Dirty pages Database
This is the primary key DeptId Name EmpId Data File – DeptId is the Clustering key Field DeptId Name EmpId 1 Jack 101 Index File 1 Steve 102 1 1 John 103 This is the primary key 2 1 Nancy 104 3 2 Rose 105 2 Abdul 106 2 Pat 107 3 Melissa 108 3 Joe 109
DeptId Name EmpId null pointer null pointer null pointer Data File – DeptId is the Clustering key Field DeptId Name EmpId 1 Jack 101 Index File 1 Steve 102 1 1 John 103 2 1 Nancy 104 3 1 David 112 2 Rose 105 2 Abdul 106 2 Pat 107 null pointer null pointer 3 Melissa 108 3 Joe 109 null pointer
Example of a B-Tree of order 3 We want to insert the following records into a B-tree of order 3 2 Jack 30,000 80 Steve 32,000 8 John 50,000 71 Nancy 55,000 15 Rose 90,000 63 Abdul 35,000 90 Pat 42,000 55 Kathy 45,000 35 Melissa 38,000 51 Joe 39,000 EmpId Name Salary
Insert index for record: 2 Jack 30,000 Null Pointer Before After 2
Insert index for record: 80 Steve 32,000 Before 2 After 2 80
Insert index for record: 8 John 50,000 Before 2 80 After 8 2 80
Insert index for record: 71 Nancy 55,000 Before 8 2 80 After 8 2 71 80
Insert index for record: 15 Rose 90,000 Before 8 2 71 80 After 8 2 15 80 71
Insert index for record: 63 Abdul 35,000 Before 8 2 15 80 71 After 8 2 15 80 71 63
Insert index for record: 90 Pat 42,000 Before 8 2 15 80 71 63 After 8 2 15 80 71 63 90
Insert index for record: 55 Kathy 45,000 Before 8 2 15 80 71 63 90 After 55 8 71 15 63 80 90 2
Insert index for record: 35 Melissa 38,000 55 8 71 15 63 80 90 2 Before After 55 8 71 15 63 80 90 2 35
Insert index for record: 51 Joe 39,000 55 Before 8 71 2 15 35 63 80 90 55 8 71 15 63 2 80 90 51 35 After
EmpId Name Salary 2 Jack 30,000 80 Steve 32,000 8 John 50,000 71 Nancy 55,000 15 Rose 90,000 63 Abdul 35,000 90 Pat 42,000 55 Kathy 45,000 35 Melissa 38,000 51 Joe 39,000 EmpId Name Salary 55 8 71 15 63 2 80 90 51 35