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

By

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