views:

185

answers:

3

I am actually stuck in 3-tier structure? I surfed the internet and found two terminology "Data Abstraction Layer" & "Data Access Layer".

What are the differences among them?

A: 

I think they are different?

From my point "Data Access Layer" should contain the methods to holds the queries to modify data like insert or update the database, where as "Data Abstraction Layer" should hold modules to retrieve the data.

Starx
You don't think that a select is "access"? That's backwards.
ryeguy
but thats what i said, access layer should hold codes to insert updateand abstraction should hold retrieval
Starx
+1  A: 

Data Access Layer= Create, Read, Update, Delete (CRUD) operations specific to your application domain

Data Abstraction Layer= performs generic database operations like connections, commands, parameters insulating you from vendor specific data libraries and providing one high level api for accessing data regardless of whether you use MySQL, Microsoft SQL Server, Oracle, DB2, etc...

Craig McKeachie
+2  A: 

My understanding is that a data access layer does not actually abstract the database, but rather makes database operations and query building easier.

For example, data access layers usually have APIs very similar to SQL syntax that still require knowledge of the database's structure in order to write:

$Users->select('name,email,datejoined')->where('rank > 0')->limit(10);

Data abstraction layers are usually full blown ORM's (Object-Relational Mappers) that theoretically prevent the need to understand any underlying database structure or have any knowledge of SQL. The syntax might be something like this:

Factory::find('Users', 10)->filter('rank > 0');

And all the objects might be fully populated with all the fields, possibly joined with any parent or child objects if you set it that way.

However, this abstraction comes with a price. I personally find ORM's like doctrine or propel to be unnecessary and inefficient. In most cases a simple data access layer will do fine, with manual SQL for anything that requires special attention, instead of having to destroy your application's performance for some syntactic sugar. This area is a pretty heated debate so I won't go into it anymore.

Edit: If you meant data*base* abstraction layer, then it would be something along the lines of PDO, so that your code can be used for a larger number of database vendors. PDO works with MySQL, PostgreSQL, and mysqli among others, I believe.

Lotus Notes