Home

ORMs

An object-relational mapper (ORM) is a software library that maps between in-memory objects and relational database tables. It provides an object-oriented interface for data access while translating operations to SQL under the hood, reducing boilerplate queries and manual result handling.

Core concepts include models or entities that correspond to database tables, attributes that map to columns,

How it works: developers define classes and mappings; the ORM builds SQL, executes it, and materializes results

Advantages include faster development, cleaner code, and improved portability across databases. Disadvantages include potential performance pitfalls

Common examples are Hibernate (Java), SQLAlchemy (Python), Django ORM (Python), Entity Framework (C#), ActiveRecord (Ruby on

and
relationships
that
represent
foreign
keys
(one-to-one,
one-to-many,
many-to-many).
Most
ORMs
implement
patterns
such
as
the
identity
map
and
unit
of
work
to
track
changes
to
objects
and
persist
them
within
a
single
transaction.
They
typically
manage
database
connections,
generate
SQL,
offer
a
query
API,
and
may
provide
schema
migrations
to
evolve
the
database
alongside
code.
into
objects.
It
can
support
lazy
loading,
eager
loading,
and
caching.
Migrations
help
keep
the
database
schema
in
sync
with
the
application's
data
models.
(notably
N+1
queries),
abstraction
leakage
that
hides
SQL
behavior,
reduced
control
over
specialized
queries,
and
complexity
with
intricate
data
access
patterns.
Rails),
and
Eloquent
(PHP).
ORMs
are
well-suited
for
CRUD-heavy
applications
and
rapid
development
when
the
data
model
aligns
with
object-oriented
design;
micro-ORMs
offer
lighter-weight
alternatives
when
finer
control
is
needed.