Refactored "db.getOrInsertName(name)"