writing db internals