Data access layer: Difference between revisions

Content deleted Content added
rewrote last para in 3rd person; other copyedits
Adding local short description: "Layer of a computer program", overriding Wikidata description "layer of a computer program which provides simplified access to data stored in persistent storage of some kind, such as an entity-relational database"
 
(64 intermediate revisions by 48 users not shown)
Line 1:
{{Short description|Layer of a computer program}}
A '''data access layer''' ('''DAL''') in computer software is a [[layer (object-oriented design)|layer]] of a [[computer program]] which provides simplified [[access]] to [[data]] stored in [[persistent storage]] of some kind, such as an [[entity relationship|entity-relational]] [[database]]. This [[acronym]] is prevalently used in [[Microsoft]] environments.
 
For example, the DAL might return a reference to an [[object (computer science)|object]] (in terms of [[object-oriented programming]]) complete with its attributes instead of a [[row (database)|row]] of [[Field (computer science)|fields]] from a database [[table (database)|table]]. This allows the [[Client (computing)|client]] (or user) modules to be created with a higher level of [[abstraction]]. This kind of model could be implemented by creating a class of data access methods that directly reference a corresponding set of database stored procedures. Another implementation could potentially retrieve or write records to or from a file system. The DAL hides this complexity of the underlying data store from the external world.
This data access layer is used in turn by other program modules to access and manipulate the data within the data store without having to deal with the complexities inherent in this access.
 
For example, instead of using commands such as ''insert'', ''delete'', and ''update'' to access a specific table in a database, a class and a few stored procedures could be created in the database. The procedures would be called from a method inside the class, which would return an object containing the requested values. Or, the insert, delete and update commands could be executed within simple functions like ''registeruser'' or ''loginuser'' stored within the data access layer.
For example, the DAL might return a reference to an [[object (computer science)|object]] (in terms of [[object-oriented programming]]) complete with its attributes instead of a [[row]] of [[Field (computer science)|fields]] from a database [[table (database)|table]]. This allows the client (or user) modules to be created with a higher level of [[abstraction]]. This kind of model could be implemented by creating a class of data access methods that directly reference a corresponding set of database stored procedures. Another implementation could potentially retrieve or write records to or from a file system. The DAL hides this complexity of the underlying data store from the external world.
 
Also, business logic methods from an application can be mapped to the data access layer. So, for example, instead of making a query into a database to fetch all users from several tables, the application can call a single method from a DAL which abstracts those database calls.
For example, instead of using commands such as ''insert'', ''delete'', and ''update'' to access a specific table in a database, a class and a few stored procedures could be created in the database. The procedures would be called from a method inside the class, which would return an object containing the requested values.
 
Applications using a data access layer can be either database server dependent or independent. If the data access layer supports multiple database types, the application becomes able to use whatever databases the DAL can talk to. In either circumstance, having a data access layer provides a centralized ___location for all calls into 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 DAL for a given application).
[[Object-Relational Mapping]] tools provide data layers in this fashion, following the [[Active record pattern|active record]] model.
 
[[Object-Relational Mapping]] tools provide data layers in this fashion, following the [[Active record pattern|activeActive recordRecord]] or [[Data mapper pattern|Data Mapper]] patterns. The [[Object-relational mapper|ORM]]/active-record model is popular with web frameworks.
[[Category:Databases]]
 
==See also==
{{database-stub}}
*[[Data access object]]
*[[Database abstraction layer]]
 
==References==
{{Reflist}}
 
==External links==
*[http://msdn.microsoft.com/en-us/library/ee658127.aspx Microsoft Application Architecture Guide]
*[http://www.asp.net/web-forms/tutorials/data-access/introduction/creating-a-data-access-layer-cs ASP.NET DAL tutorial]
 
[[Category:Object-oriented programming]]
[[Category:Data mapping]]
[[Category:Databases]]