Notes on ORM — Part I

ORM Object Relational Mapping is the technique of accessing a relational database using an object-oriented programming language.

How does ORM work?

  • This “Mapping” is essentially a design pattern that translates our program and makes it accessible to a database.
  • Persists information into a database efficiently; You don’t have to learn complex queries to write code specific to a database.
  • There are many different implementations of ORMs for object-oriented programming languages (Hibernate for Java, Doctrine for PHP, SQLAlchemy for Python, etc)….In Ruby the most commonly used is ActiveRecord.
  • The ORM calls the database for you, “wrapping” the data. It allows you to connect and interact with the SQL data as though it were a Ruby object.
  • In Ruby, classes are mapped to or equated with tables and instances of a class are equated to table rows.