🗄️ Database beginner

ORM (Object-Relational Mapping)

Programming technique that converts data between object-oriented code and relational databases.

ORMs let you interact with databases using your programming language's objects instead of raw SQL. Benefits: type safety, easier refactoring, database abstraction, and protection against SQL injection. Popular ORMs: SQLAlchemy (Python), Prisma/Drizzle (TypeScript), ActiveRecord (Ruby), Entity Framework (.NET). Trade-offs: ORMs can generate inefficient queries, hide database complexity, and add learning curves. The N+1 query problem is a common pitfall where lazy loading causes excessive queries. Many developers use ORMs for simple operations and raw SQL for complex queries. Understanding both ORM patterns and underlying SQL makes you effective with either approach.