Design patterns·Objects and the database between them
the object has a save method on it, so the thing that models an order also knows the table it lives in.
Active record
Also calledactive record pattern, model with save
An object that wraps a row and carries both the domain logic and its own persistence — `user.save()`. It is fast to write and reads well when the object model and the table are close to a one-to-one match, which is most CRUD applications. The bill arrives when they diverge: the domain object cannot be tested without a database, cannot be modelled independently of the schema, and quietly acquires a second responsibility it can never give back.