concept

Table Data Gateway Pattern

The Table Data Gateway Pattern is a data access design pattern that provides an object-oriented interface to a database table, acting as a gateway between the application and the database. It encapsulates all SQL queries and operations for a single table, such as insert, update, delete, and select, into a dedicated class. This pattern helps separate data access logic from business logic, making the codebase more maintainable and testable.

Also known as: Table Gateway Pattern, Gateway Pattern, Data Gateway Pattern, Table Data Gateway, TDG Pattern
🧊Why learn Table Data Gateway Pattern?

Developers should use this pattern when building applications that require simple, direct access to database tables without complex business rules or relationships, such as in CRUD-heavy systems or legacy codebases. It is particularly useful for reducing code duplication in data access layers and providing a clear abstraction over database operations, though it may not be suitable for complex domain models where patterns like Repository or Data Mapper are more appropriate.

Compare Table Data Gateway Pattern

Learning Resources

Related Tools

Alternatives to Table Data Gateway Pattern