As a learning exercise I am attempting to write a simple embedded database in C#. Everything is going fine but I am getting really stuck when it comes to saving the data to disk.
As an example of one of my problems.. I may need to "insert" data into the middle of the data file. This clearly isn't possible with sequential file access. Re-writing the entire last half of the file every time there is an insert isn't an option for obvious performance reasons.
The only solution I can imagine is to write each table followed by some empty space in the file. The empty space will be used to write new data, and the file will need restructuring / growing each time a table uses up its available space.
I guess my questions are.. exactly what does the data "look like" inside a typical DB's data file? How / where is new data written in the file?