Read and write from database

closes #2
miscellaneous fixes
write never before seen objects to database
retrieve known objects from database