If the answer you're looking for is “what kind of book to read,” I can't help.
If “how to do this” may be good for you, I have some suggestions.
One good solution is the proposal proposed by Srikar; I would just add that instead of SQLI I would use SQLite. This is an open source C library that you can embed in your program. It allows you to store data in the database in the same way as with the SQL statement, but instead call the functions of the C library. In your case, you can store everything in memory and then save the data to disk at the right time.
Link: http://www.sqlite.org
Another option is the old do-it-yourself. I mean: there is nothing complicated in storing your data in a file (if your data is not very structured, but in this case I would choose option No. 1).
You write down a plan of how you want your file structure to be. And you follow this plan both when writing a file to disk, and when reading it overwriting data into memory.
If you have entries n . Write n to disk, then write each entry.
If each record has a variable length, then record the length of each record before recording the record.
You are talking about "random access" in your question. You probably mean that the file is very large and during access you want to read from the disk only the part you are interested in.
If you plan to build an index; this index will report the offset of each element in bytes from the beginning of the file. Save the index at the beginning of the file, and then save the data.
When you read a file, you begin to read the index, get the offset of the data you need, and read this part of the file.
These are very simple examples, just to get an idea ...
Hope they help!