more work on database.js -- trying to get it to a good point to implement the new schema