What is ORM?

ORM stands for Object-Relational Mapping. ORM libraries map database tables to classes, rows of those tables to objects of the class, and columns to object attributes. Object wraps a row of a database table or view, encapsulates the database access, and adds domain logic on that data.

ORM connects business objects and database tables to create a domain model where logic and data are presented in one wrapping.

In addition, the ORM classes wrap our database tables to provide a set of class-level methods that perform table-level operations. For example, we might need to find the Employee with a particular ID. This is implemented as a class method that returns the corresponding Employee object. In Ruby code, this will look like:

employee= Employee.find(1)

This code will return an employee object whose ID is 1.