Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

database
library
oop

What is Object Relational Mapping?

Educative Answers Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

svg viewer

What is ORM?

Object Relational Mapping (ORM) is the bridge between databases and object-oriented programming. The ORM equips you with object-oriented tools to run commands that you would usually run on databases. It masks out the complicated intricacies of the databases and lets you manipulate them with your choice of programming language (must support object-oriented programming).

Pros

  • It is easier to query using ORM than MySQL.
  • Hides the complex processes under-the-hood and only lets you worry about the high-level implementation.
  • There is no need to change the code if the underlying database changes.

Cons

  • Learning an ORM from scratch is time-consuming.
  • You cannot directly dive into an ORM without learning MySQL. Even though the ORM helps you abstract the complex details, it is pertinent to know the consequence of each command under-the-hood.
  • You may run into performance issues while coding complex queries using an ORM.

Example

There is a wide range of ORMs in different object-oriented programing languages. Let’s consider the following MySQL query:

$value = SELECT * FROM collection WHERE day = 'Monday' 

The above query retrieves a value from the table collection in which columns (day) are equal to Monday.

In an ORM, this query would look something like this:

value = collection.query(day = 'Monday')

Here is a list of ORM libraries in different object-oriented programming languages.

RELATED TAGS

database
library
oop
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring