ORM · Object-Relational Mapping
/ oh-arr-EMM /
An ORM is a tool that lets you work with database rows as ordinary objects in your code, so you can read and save data without hand-writing SQL for every little thing. You call user.save() or User.find(1), and the ORM quietly translates that into the SELECT and INSERT statements the database actually wants.
Think of it as a bilingual go-between. Your code speaks in objects and methods; the database speaks in tables and SQL. The ORM sits in the middle, turning a row of columns into a tidy object you can poke at, and turning your changes back into SQL when it's time to save.
The appeal is less boilerplate and code that reads like your problem instead of like database plumbing. The catch is that the convenience can hide what's really happening — an innocent-looking loop might secretly fire hundreds of queries — so it pays to know the SQL underneath even when the ORM is writing it for you.
# With an ORM user = User.objects.get(id=1) # What it runs underneath # SELECT * FROM users WHERE id = 1;
One line of object code; the ORM writes the SQL for you.
An ORM doesn't replace knowing SQL — for tricky or performance-critical queries, most teams still drop down to hand-written SQL.