Database Technologies

What is an ORM? Object-relational mapping explained

What an ORM (object-relational mapper) does: classes map to tables and objects to rows, the SQL it writes for you, the N+1 query trap and when to use plain SQL.

  • 6 min read
  • 5 questions
  • +35 XP
Transcript

ORM, explained by cats. Kitty has an app. And a database. The database speaks SQL. Kitty speaks code. That’s a problem. Kitty doesn’t want to write raw SQL every time she needs data. Too many queries. Too many joins. Too many chances to break things.

So Kitty uses an ORM. ORM means Object-Relational Mapper. It’s a translator cat. Between Kitty’s code and the database. Kitty says: get all users The ORM turns that into SQL behind the scenes. Classes map to tables. Objects map to rows.

Properties map to columns. That’s an ORM. a translator cat that helps code talk to tables without meowing raw SQL every time