"How can I use vehicles moving through a network of roads to build a working model of an internal combustion engine?"
http://tunes.org/wiki/abstraction_20inversion.html
The best practice here is to just let the database be built up of B-Trees (or whatever) at the low level and use it like a database.