Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

orm
ruby on rails

What is Object Relational Mapping in ROR?

Dian Us Suqlain

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.

Answers Code

ORM - Object Relational Mapping is a framework written in OOP Languages such as Java, Python, and Ruby. This framework wraps around a relational database such as MySQL.

ORM is a programming technique for converting data between incompatible systems in OOP languages. It also ensures that you do not have to call a database yourself.

ORM Framework and Ruby

Advantages

This concept of ORM is effective when dealing with databases.

Note: Not all ORM implementations support each of the following advantages.

In Ruby on Rails, ORM is:

  • Database Independent - There is no need to write code in a particular database. Simply start a project using MySQL and change it to SQLite later on.
  • Reduces Code - ORM provides the concept of abstraction, which means there’s no need to repeat the same code again and again.
  • Rich Query Interface - ORM allows the developer to get rid of the complex semantics of SQL.

ActiveRecords is a powerful framework of ORM in Ruby on Rails. Using the functionality provided by this module, you can:

  • Establish a connection to a database
  • Create database tables
  • Specify associations between tables that correspond to associations between the Ruby classes
  • Establish an ORM between Ruby classes/objects/attributes and the tables/rows/columns in the underlying database
  • Perform CRUD operations on Ruby ActiveRecord objects

Disadvantages

The ORM model is helpful in Ruby code completion and in implementing frameworks to reduce workload. However, it is still lacking in some areas, such as:

  • Overhead Issues - ORM consumes more memory than other relational databases and increases CPU usage.

  • Performance Issues - Some actions, such as inserting a large data, updating it, deleting it, etc., are slower when implemented using ORM. Native SQL queries can usually handle these actions more efficiently.

RELATED TAGS

orm
ruby on rails

CONTRIBUTOR

Dian Us Suqlain
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.

Answers Code
Keep Exploring