# Data Access Objects

A data access object (DAO) is a class that holds the database code for one table, so the rest of your program calls methods like getAllCategories() instead of writing SQL.

Journeyman · Java · SQL · Updated November 16, 2026

By Gregor Dzierzon

It is a standard practice to create a class that is dedicated to interacting with the database. These classes/objects are called Data Access Objects (DAOs).

When you need a list of Categories, you don't need to re-write the logic. Instead you call the `getAllCategories()` function in the Categories DAO.

It is common to have one DAO per database table. Each DAO is an expert in all CRUD operations for their table.

## Cheat sheets

- [Data Access Objects](https://www.ask-codey.com/cheat-sheets/mapping-data-to-models-data-access-objects-cheat-sheet)

Source: https://www.ask-codey.com/lessons/mapping-data-to-models-data-access-objects
