I try to build a very small object database, not for production only to learn a bit in my spare time. I've got a data structure that saves my data in blocks of a specific size und combine them when more data is needed. But now my problem is when I do it this way I would need one file per object type I want to save (the same goes for my B Tree Index file), how would I design the database file to save different object types in the same one?

1 Answer 1


If you save small data structures like records or nodes of an index tree to the disk using normal file io, you’d typically use one file per data structure.

You can very well combine several structures in the same file, by using a file layout where at the beginning of the file you indicate where to find what.

A frequently used approach for this, is a paged file layout. You structure file data into larger fixed size blocs called “page”. Each page is dedicated to one kind of data structure. You then allocate a new page when you need more space for a particular data structure. You’d also need to manage the table content (list of pages, start page of each data structure, ...) in order to find back your content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.