What are some examples of good class structures used to manage database access? I am a fan of class encapsulation and would prefer the containers (e.g. car) not to perform database tasks.
I would also like the ability to easily drop in things like a database cache in future.
I often take the pattern of container classes, complete with getters and setters for validation and database access performed by a single singleton class. That being said, this often gets mixed between the two and becomes quite confusing.
Sorry if my question is hard to understand; I'm not absolutely sure on terms regarding databases. Please feel free to ask for clarification if needed.