next up previous contents
Next: Optimization Up: 4660 Previous: Algorithm to Decompose R   Contents

Index Mechanisms [275]





Direct

sql_select all from S where 'S.S#=="S3"'



Range

sql_select all from S
where '(S.CITY>="London")&&(S.CITY<="Paris")'



Problem



Solution



B+tree, Inverted File [276]





\begin{picture}(760,453)(20,360)
\thicklines\put(220,380){\framebox (400,200){}}...
...0,360){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{Supplier File}}}
\end{picture}



Index Mechanisms: B-tree, B+tree [277]



B-tree



B+tree



VISUAL Btree [278]



VDB



Demo

Insert

Overflow

New Root

Delete

Underflow



B-tree: Find, Read, Next [279]



Find(key)



Read(data)



Next()



B-tree: Insert(key) [280]



Insert(key)



B-tree: Find, Insert [281]

Order: 5 (max 5 children/node; max 4 keys/node; min 2 keys/node)




Find: h, x


\begin{picture}(580,80)(20,740)
\thicklines\put( 20,740){\framebox (100,20){}}
\...
...t(505,745){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt s t x}}}
\end{picture}




Insert: u (OK)


\begin{picture}(580,80)(20,740)
\thicklines\put( 20,740){\framebox (100,20){}}
\...
...505,745){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt s t u x}}}
\end{picture}



B-tree: Insert (Overflow) [282]

Insert: p (Overflow)


\begin{picture}(580,80)(20,740)
\thicklines\put( 20,740){\framebox (100,20){}}
\...
...505,745){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt s t u x}}}
\end{picture}




Split; Promote m; Overflow


\begin{picture}(700,80)(20,740)
\thicklines\put(260,800){\framebox (100,20){}}
\...
...625,745){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt s t u x}}}
\end{picture}




Split; Promote j; New Root


\begin{picture}(700,140)(20,680)
\thicklines\put( 20,680){\framebox (100,20){}}
...
...625,685){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt s t u x}}}
\end{picture}



B-tree: Delete(key) [283]



Delete(key)



B-tree: Delete [284]

Delete: h (OK)


\begin{picture}(700,140)(20,680)
\thicklines\put( 20,680){\framebox (100,20){}}
...
...625,685){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt s t u x}}}
\end{picture}




Delete: r (Not on leaf; Swap with successor on leaf s; Delete OK)


\begin{picture}(700,140)(20,680)
\thicklines\put( 20,680){\framebox (100,20){}}
...
...{\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{$\not${\tt r t u x}}}}
\end{picture}



B-tree: Delete (Underflow) [285]

Delete: p (Underflow)


\begin{picture}(700,140)(20,680)
\thicklines\put( 20,680){\framebox (100,20){}}
...
...t(625,685){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt t u x}}}
\end{picture}




Borrow from neighbor; Moveleft s t


\begin{picture}(700,140)(20,680)
\thicklines\put( 20,680){\framebox (100,20){}}
...
...put(625,685){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt u x}}}
\end{picture}



B-tree: Delete (Combine) [286]

Delete: d (Underflow; Cannot borrow)


\begin{picture}(700,140)(20,680)
\thicklines\put( 20,680){\framebox (100,20){}}
...
...put(625,685){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt u x}}}
\end{picture}



Combine a b c e; Remove old page; Underflow


\begin{picture}(700,140)(20,680)
\thicklines\put( 20,680){\framebox (100,20){}}
...
...put(625,685){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt u x}}}
\end{picture}



Combine f j m t; Remove old root


\begin{picture}(580,80)(20,740)
\thicklines\put( 20,740){\framebox (100,20){}}
\...
...put(505,745){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\tt u x}}}
\end{picture}



Index Mechanisms: Performance [287]



DD

DD has information about indices for the database. SQL uses this information for fast queries.



Direct

sql_select all from S where 'S.S#=="S3"'



B-tree



Range

sql_select all from S
where '(S.CITY>="London")&&(S.CITY<="Paris")'



B+tree



Access Hierarchy [288]




\begin{picture}(345,360)(75,460)
\thicklines\put(260,760){\framebox (140,60){}}
...
...ox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{\twlrm request stored page}}}
\end{picture}



[DBMS Example [289]



File Manager [290]



Clustering [291]



Storage Layout [292]



0 Directory S1 S2 S3 S4 S5
6 P1 P2 P3 P4 P5 P6
12 S1/P1 S1/P2 S1/P3 S1/P4 S1/P5 S1/P6
18 S2/P1 S2/P2 S3/P2 S4/P2 S4/P4 S4/P5
24            
30            





Storage Layout [293]



0 Directory S1 P7 S3 empty S5
6 P1 P2 P3 P4 P5 P6
12 S1/P1 S1/P2 S1/P3 S1/P4 S1/P5 S1/P6
18 S2/P1 S2/P2 S3/P2 S4/P2 S4/P4 S4/P5
24 S6          
30            




next up previous contents
Next: Optimization Up: 4660 Previous: Algorithm to Decompose R   Contents
Ted Billard 2001-10-31