Introduction to ORMs

01 Min

An Object-Relational Mapper (ORM) is a programming technique (or library) that lets developers interact with relational databases (like MySQL, PostgreSQL, Oracle, SQL Server) using objects in their programming language instead of writing raw SQL.


Why ORMs exists

Applications are usually written using objects, classes, and programming language data structures.

Relational databases, however, store data in tables, rows and columns.

ORM bridges that gap between object-oriented code and relational databases.


With and Without an ORM

  • Without ORM: You write SQL queries directly
SELECT * FROM users WHERE active = true;
  • With ORM: You call methods on objects and ORM translates that into SQL.
User.find({ active: true })

ORM vs Raw SQL

ORMRaw SQL
Faster developmentMore control
Cleaner abstractionsBetter for complex queries
Easier CRUD operationsEasier low-level optimization
Generates SQL automaticallyManual query writing

Examples of ORMs in Different Tech Stack

LanguageORM
JavaHibernate
PythonSQLAlchemy
JavaScript / TypeScriptPrisma
JavaScript / TypeScriptSequelize
RubyActive Record
PHPLaravel Eloquent
C#Entity Framework

Each ORM has its own philosophy:

  • Hibernate (Java): Very feature-rich, supports lazy loading, caching, complex mappings.
  • SQLAlchemy (Python): Flexible, lets you mix ORM with raw SQL.
  • Prisma (JS/TS): Type-safe, modern, schema-first approach