Migrated most of DatabaseManager from assignment3