ORM (Object-Relational Mapper)
What is ORM (Object-Relational Mapper)?
ORM (Object-Relational Mapper): A library that translates between your application's objects and database tables, so you can interact with a database using your programming language rather than raw SQL. An ORM, or object-relational mapper, translates between database tables and objects in your code. Instead of writing SQL for every query, you work with classes like Order and methods like $order->customer.
Frequently asked questions about ORM (Object-Relational Mapper)
How is ORM (Object-Relational Mapper) used in practice?
Laravel's Eloquent, Doctrine for PHP, Prisma for Node and SQLAlchemy for Python are well-known examples. They speed up development, prevent SQL injection by using parameter binding, and make code easier to read.
What should you keep in mind with ORM (Object-Relational Mapper)?
The abstraction has costs. It is easy to trigger many small queries without noticing, such as loading each order's customer inside a loop. Eager loading with with() fixes that. For complex reports, writing the query directly or using the query builder is often clearer and faster. Learn to look at the SQL your ORM produces; tools like Laravel Debugbar or Telescope show it.
At a glance
| Category | Core glossary |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |