OR Mapping
This page was created by Stephanie@mdriven.net on 2024-05-09. Last edited by Edgar on 2025-01-20.

Object-relational mapping (also ORM and O/R Mapping) is a technique used in software engineering to bridge the gap between object-oriented programming (OOP) and relational databases. OR Mapping converts data between a database and an object-oriented programming language.

ORM allows developers to work with database records as if they were objects in their programming language, abstracting away the complexities of SQL queries and database interactions.

How Does ORM Work?

  • Mapping: ORM maps database tables to classes (objects) in the application code.
  • CRUD Operations: Developers can perform CRUD (Create, Read, Update, Delete) operations on objects, and the ORM translates these actions into corresponding SQL statements.
  • Relationships: ORM handles relationships (such as one-to-many, many-to-many) between objects and their associated database tables.

Benefits of ORM:

  • Productivity: Developers can focus on business logic rather than writing raw SQL queries.
  • Portability: ORM makes it easier to switch between different database systems (e.g., MySQL, PostgreSQL, SQLite) without changing application code.
  • Security: ORM helps prevent SQL injection attacks by parameterizing queries.
  • Abstraction: Developers work with objects, abstracting away low-level database details.


ORM simplifies database interactions by allowing developers to work with objects in their code, while the ORM handles the underlying database operations. It’s a powerful tool for building robust and maintainable software systems. 🚀📊

Learn more here: https://builtin.com/data-science/object-relational-mapping

See also: Type mapping, OR-Mapping, Working with Code and Persistence Mapping