What is an ORM and what are its trade-offs?

Answer

An ORM (Object-Relational Mapper) maps database tables to classes and rows to objects in your programming language, allowing you to query and manipulate data using the language's native paradigm instead of writing SQL. Examples: Hibernate (Java), ActiveRecord (Rails), SQLAlchemy (Python), Entity Framework (.NET), Eloquent (Laravel). Benefits: faster development, database abstraction (switch RDBMS with minimal code changes), protection against SQL injection (parameterized queries). Trade-offs: generated SQL can be inefficient or cause N+1 queries, learning curve of the ORM API, and complex queries are often cleaner in raw SQL. Most ORMs allow dropping to raw SQL when needed.