Data Access Layer


A data access layer (DAL) in computer programs is a layer of a computer program that provides simplified access to data stored in persistent storage of some kind, such as an entity - database relationship. This acronym is used predominantly in Microsoft ASP.NET environments.

For example, the DAL could return a to the object (in terms of object-oriented programming) complete with its attributes instead of a field record of a database table. This allows the client (or user) modules to be created with a higher level of abstraction. This type of model can be implemented by creating a class of data access methods that refer directly to a corresponding set of stored database procedures. Another potential application could retrieve or write records to or from a file system. The DAL hides that complexity of the underlying data store from the outside world.

For example, instead of using commands such as insert, delete and update to access a specific table in a database, a class and stored procedures could be created in the database. Procedures have been called from a method within the class, which would return an object containing the requested values. Or the insert, delete, and update commands could be executed in simple functions such as registerUser or loginUser stored within the data access layer.

In addition, the business logic methods of an application can be assigned to the data access layer. So, for example, instead of doing a query in a database looking for all the users of several tables of the application can call a single method of a DAL that abstracts the so-called databases.

Applications that use a data access layer can be any of the dependent or stand-alone database servers. If the data access layer is compatible with various types of databases, the application becomes able to use what the databases of the CHA can talk about. In any circumstance, having a data access layer provides a centralized location for all calls in the database, and thus makes it easier to port the application to other database systems (assuming that 100% of the database interaction is done in the CHA for a given application).

Object-relational mapping tools provide data layers in this way, following the active record model. The ORM / active-record model is popular among web application frameworks.

wiki