Move some database access code out of Schema and into Database.