I know how to implement btree in memory, but not clear about how to store btree in disc. I think there are two major difference:
Thanks
Disk platters are formatted in a system of concentric circles, or rings, called tracks. Within each track are sectors, which subdivide the circle into a system of arcs, each formatted to hold the same amount of data—typically 512 bytes.
A B-tree of order m is a search tree in which each nonleaf node has up to m children. The actual elements of the collection are stored in the leaves of the tree, and the nonleaf nodes contain only keys.
In computer science, a B-tree is a self-balancing tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time. The B-tree generalizes the binary search tree, allowing for nodes with more than two children.
it all depends on DBMS you use. If you wanna know how it is implemented in MS SQL Server, things to read about are:
Using IAM and GAM (or SGAM) you can split page - just move part of the page (which is supposed to be overflowed) to the another page on file.
IAM and GAM are also answers to your first question.
Most of these names are taken from MS SQL Server but I'm pretty sure, that in other DBMS's it is solved quite similar.
Hope it helps.
My recommendation is to have a look at the book Database System Implementation"
Chapter 2 "data storage" and chapter 3 "representing data elements" wil give you some hints about this problem.
Chapter 4 index structures has a section on Btrees
It's the best source of information I have found so far on this topic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With