Active Record ORM and Migrations

Many modern Frameworks in web development use MVC architecture.  Traditionally in the model layer developers need to create Model Classes, database tables and usually a base class which handles the  data query process.

Active Record pattern in Object Relational Mapping system is a modern approach to make this process simpler.

First there is naming conventions:

If the Model Class Name is Article, the data table should be articles:

  • Primary Key is usually id.
  • foreign key is usually singularized_table_name_id
  • and there is created_at and updated_at which save a timestamp of the operation

then depends on the language you use there will be very simple CRUD functions which can be used.

Migrations is just another abstract layer provided at the framework layer which support different database version which save your effort on managing each of them