Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between DAO and DAL?

Having studied Java at school I am quite familiar with the DAO-pattern(Data access object). However at work I use .NET. In .NET there is often talk about the DAL(Data Access Layer). To me their purpose seems quite similar. So the question is are DAO and DAL basically the same thing? Is the term DAL only made up so it wouldn't be mixed up with Data Access Objects?

like image 804
simoraman Avatar asked Jul 06 '09 11:07

simoraman


People also ask

What is difference between DAO and DTO?

DAO is a class that usually has the CRUD operations like save, update, delete. DTO is just an object that holds data. It is JavaBean with instance variables and setter and getters. The DTO is used to expose several values in a bean like fashion.

What is a DAL coding?

A data access layer (DAL) in computer software is a layer of a computer program which provides simplified access to data stored in persistent storage of some kind, such as an entity-relational database. This acronym is prevalently used in Microsoft environments.

Is DAO same as ORM?

ORM and DAO are orthogonal concepts. One has to do with how objects are mapped to database tables, the other is a design pattern for writing objects that access data. You don't choose 'between' them. You can have ORM and DAO is the same application, just as you don't need ORM to use the DAO pattern.

What is DAO used for?

The Data Access Object (or DAO) pattern: separates a data resource's client interface from its data access mechanisms. adapts a specific data resource's access API to a generic client interface.


2 Answers

The Data Access Layer (DAL) is the layer of a system that exists between the business logic layer and the persistence / storage layer. A DAL might be a single class, or it might be composed of multiple Data Access Objects (DAOs). It may have a facade over the top for the business layer to talk to, hiding the complexity of the data access logic. It might be a third-party object-relational mapping tool (ORM) such as Hibernate.

DAL is an architectural term, DAOs are a design detail.

like image 106
Matt Howells Avatar answered Sep 23 '22 22:09

Matt Howells


A data access layer will contain many data access objects.

It's primary role is to decouple the business logic from the database logic and implementation.

For example the DAL may have a single method that will retrieve data from several tables, queries or stored procedures via one or more data access objects.

Changes to the database structure, DAOs, stored procedures or even database type should not incur changes to the business logic and this is down to the decoupling provided by the DAL.

like image 22
ChrisBD Avatar answered Sep 24 '22 22:09

ChrisBD