database model working with sqlite and in-memory db
merged in master