Questions tagged [data-access-layer]

Data access layer 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.

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.

For example, the DAL might return a reference to an object (in terms of object-oriented programming) complete with its attributes instead of a row of fields from a 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.

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.

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.

1287 questions
609
votes
9 answers

Separation of business logic and data access in django

I am writing a project in Django and I see that 80% of the code is in the file models.py. This code is confusing and, after a certain time, I cease to understand what is really happening. Here is what bothers me: I find it ugly that my model level…
562
votes
14 answers

What is the difference between DAO and Repository patterns?

What is the difference between Data Access Objects (DAO) and Repository patterns? I am developing an application using Enterprise Java Beans (EJB3), Hibernate ORM as infrastructure, and Domain-Driven Design (DDD) and Test-Driven Development (TDD) as…
94
votes
12 answers

Repository Pattern vs DAL

Are they the same thing? Just finished to watch Rob Connery's Storefront tutorial and they seem to be similar techinques. I mean, when I implement a DAL object I have the GetStuff, Add/Delete etc methods and I always write the interface first so…
Mike
  • 981
  • 1
  • 7
  • 5
77
votes
11 answers

How to write unit tests for database calls

I'm near the beginning of a new project and (gasp!) for the first time ever I'm trying to include unit tests in a project of mine. I'm having trouble devising some of the unit tests themselves. I have a few methods which have been easy enough to…
63
votes
2 answers

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…
simoraman
  • 919
  • 1
  • 8
  • 13
61
votes
12 answers

What is the best way to improve performance of NHibernate?

I have an application that uses NHibernate as its ORM and sometimes it experiences performance issues due to how the data is being accessed by it. What kind of things can be done to improve the performance of NHibernate? (Please limit to one…
Ray
  • 187,153
  • 97
  • 222
  • 204
48
votes
2 answers

Should the repository layer return data-transfer-objects (DTO)?

I have a repository layer that is responsible for my data-access, which is called by a service layer. The service layer returns DTOs which are serialized and sent over the wire. More often than not, services do little more than access a repository…
JulianR
  • 545
  • 1
  • 4
  • 7
45
votes
2 answers

Object persistence terminology: 'repository' vs. 'store' vs. 'context' vs. 'retriever' vs. (...)

I'm not sure how to name data store classes when designing a program's data access layer (DAL). (By data store class, I mean a class that is responsible to read a persisted object into memory, or to persist an in-memory object.) It seems reasonable…
40
votes
3 answers

What is the difference between Database Abstraction Layer & Data Access Layer?

I am actually stuck in 3-tier structure. I surfed the internet and found two terminologies "Database Abstraction Layer" & "Data Access Layer". What are the differences between the two?
Starx
  • 77,474
  • 47
  • 185
  • 261
39
votes
3 answers

Transaction script is Antipattern?

Well there is a similar topic about transaction script with NoSQL database, but this one is about the pattern in general. From what I find about Transaction script, it is not object-oriented at all. Its basically procedural code despite the fact…
Lord Yggdrasill
  • 3,197
  • 4
  • 26
  • 42
38
votes
4 answers

Should I return IEnumerable or IQueryable from my DAL?

I know this could be opinion, but I'm looking for best practices. As I understand, IQueryable implements IEnumerable, so in my DAL, I currently have method signatures like the following: IEnumerable GetProducts(); IEnumerable
Armstrongest
  • 15,181
  • 13
  • 67
  • 106
37
votes
4 answers

Where is the line between DAL and ORM?

The terms are often thrown around interchangeably, and there's clearly considerable overlap, but just as often it seems implied that people see something strongly implied by saying that a system is an ORM that isn't implied by it being a DAL. What…
chaos
  • 122,029
  • 33
  • 303
  • 309
36
votes
4 answers

Nullable values in C++

I'm creating a database access layer in native C++, and I'm looking at ways to support NULL values. Here is what I have so far: class CNullValue { public: static CNullValue Null() { static CNullValue nv; return nv; …
DanDan
  • 10,462
  • 8
  • 53
  • 69
35
votes
2 answers

Why does an Entity Framework Connection require a metadata property?

I switched my DAL from using LINQ over to Entity Framework. Because my application connects to different databases depending on the current user, I need to dynamically create the DataContext at run time and pass in the appropriate connection…
John B
  • 20,062
  • 35
  • 120
  • 170
33
votes
10 answers

Why put a DAO layer over a persistence layer (like JDO or Hibernate)

Data Access Objects (DAOs) are a common design pattern, and recommended by Sun. But the earliest examples of Java DAOs interacted directly with relational databases -- they were, in essence, doing object-relational mapping (ORM). Nowadays, I see…
Todd Owen
  • 15,650
  • 7
  • 54
  • 52
1
2 3
85 86