What is ORM (Object-Relational Mapping)?

Turkish: ORM

ORM maps database tables as objects, allowing database operations without writing raw SQL through library abstractions.

What Is ORM?

ORM (Object-Relational Mapping) maps relational database tables to classes, models, or objects in application code. Instead of writing SQL directly against a users table, a developer might call methods such as User.findMany() or user.save().

An ORM does not remove the database; it abstracts SQL generation. Developers still need to understand which queries are produced, how indexes are used, and where transaction boundaries are.

What an ORM Provides

  • Model definitions: Representing tables and columns in code
  • Query builder: Writing filters, sorting, and relationship queries through APIs
  • Relationship handling: Modeling one-to-many and many-to-many associations
  • Migration support: Versioning schema changes
  • Type safety: Editor-level checks for model fields in some tools

Prisma, TypeORM, Sequelize, Django ORM, SQLAlchemy, Entity Framework, and Hibernate are common examples. Each comes with different language, ecosystem, and performance tradeoffs.

Business Use

ORMs speed up CRUD-heavy business applications and make model rules visible in code. Admin panels, SaaS products, CRM modules, and e-commerce backends often benefit from this approach.

Risks include N+1 queries, unnecessary eager loading, slow complex reports, and hiding database-specific capabilities. In performance-sensitive areas, generated queries should be inspected; direct SQL or PostgreSQL features may be the better tool.