samba2
samba2

Reputation: 622

What database abstraction patterns are there?

I am trying to get my head around the common patterns for database abstraction.

So far I've found:

  1. Database Layer
    • just a separate class which holds the SQL
    • does not conform to any other rules
  2. Data Access Object (DAO)
    • like above but there is a transfer object which represents the columns of the database table
    • create, delete, update methods take the filled transfer object as input
    • the find methods may take an input like string (findByName) or an integer (findByAge) but always return lists of transfer objects
  3. Repository
    • abstraction of a collection of objects
    • closer to the domain model
    • I need to read more here
  4. Object Relational Mapper
    • tool which gives me an object which is mapped to the database table in the background
    • the object represents a row in the table
    • a property change of the object leads to an update

Please don't worry too much about my quick explanations of the patterns. I am still in an understanding phase.

But is this list complete or are there other concepts which are missing here?

Upvotes: 0

Views: 1497

Answers (1)

Dave Schweisguth
Dave Schweisguth

Reputation: 37657

Martin Fowler's "Patterns of Enterprise Application Architecture" is an excellent book, well respected in the community, which documents about fifty design patterns, around half of which are concerned with interacting with databases. It includes Repository, several kinds of DAOs (more or less covering your Database Layer and DAO) and several entire categories of patterns found in object-relational mappers. So there's a good place to start.

It's hard to summarize any more of the content of POEAA in this answer without simply repeating the list of patterns. Fortunately the list can be found at Fowler's web site. Unfortunately the copyright symbol there suggests that I shouldn't just include it here.

Upvotes: 2

Related Questions