Sample of database usage and refactoring of Entity