intermediate

General data access concepts

Compare data access patterns and failure modes before choosing an ORM, repository, query builder, or hand-written SQL boundary.

General data access interviews judge pattern literacy before framework trivia. Topics: Active Record versus Data Mapper, repository boundaries, Unit of Work, query builders, migrations, lazy versus eager loading, N+1, and ORM transactions.

On interviews: walk a use case and label where objects live, when SQL runs, and what invariant a transaction protects.

Common pitfalls: pattern slogans without trade-offs; fixing performance only by switching ORM; migrations as an afterthought.

The trade-off is choosing the lightest pattern that still keeps tests and deploys safe.

Checklist:

  • Map pattern to coupling and test seams.
  • Measure query count before optimizing tools.
  • Review migration SQL like application code.
  • Keep transactions scoped to invariants.