What is ORM
Mapping objects to relational databases
ORM (Object-Relational Mapping) is a programming technology that allows working with databases through objects in code without manually writing SQL queries.
How It Works
- Database tables correspond to classes in code
- Table rows are object instances
- Columns are object properties
- Table relationships are object references
Advantages
- SQL Abstraction — working with objects instead of queries
- Security — protection from SQL injections
- Portability — switching databases without code changes
- Productivity — less boilerplate code
Disadvantages
- Performance degradation on complex queries
- Additional abstraction layer
- Learning curve for advanced features
Popular ORMs
- Python: SQLAlchemy, Django ORM
- JavaScript: Prisma, TypeORM, Sequelize
- Java: Hibernate, JPA
- C#: Entity Framework
- Ruby: ActiveRecord