{"id":63,"date":"2018-09-27T13:26:23","date_gmt":"2018-09-27T03:26:23","guid":{"rendered":"http:\/\/www.kernelio.com\/blog\/?p=63"},"modified":"2018-09-27T13:26:23","modified_gmt":"2018-09-27T03:26:23","slug":"active-record-orm-and-migrations","status":"publish","type":"post","link":"https:\/\/www.kernelio.com\/blog\/2018\/09\/27\/active-record-orm-and-migrations\/","title":{"rendered":"Active Record  ORM and Migrations"},"content":{"rendered":"<p>Many modern Frameworks in web development use MVC\u00a0architecture.\u00a0 Traditionally in the model layer developers need to create Model Classes, database tables and usually a base class which handles the\u00a0 data query process.<\/p>\n<p>Active Record pattern in\u00a0Object Relational Mapping system is a modern approach to make this process simpler.<\/p>\n<p>First there is naming conventions:<\/p>\n<p>If the Model Class Name is Article, the data table should be articles:<\/p>\n<ul>\n<li>Primary Key is usually id.<\/li>\n<li>foreign key is usually\u00a0singularized_table_name_id<\/li>\n<li>and there is\u00a0created_at and updated_at which save a timestamp of the operation<\/li>\n<\/ul>\n<p>then depends on the language you use there will be very simple CRUD functions which can be used.<\/p>\n<p>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<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many modern Frameworks in web development use MVC\u00a0architecture.\u00a0 Traditionally in the model layer developers need to create Model Classes, database tables and usually a base class which handles the\u00a0 data query process. Active Record pattern in\u00a0Object Relational Mapping system is a modern approach to make this process simpler. First there is naming conventions: If the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-software-engineering"],"_links":{"self":[{"href":"https:\/\/www.kernelio.com\/blog\/wp-json\/wp\/v2\/posts\/63","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kernelio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kernelio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kernelio.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kernelio.com\/blog\/wp-json\/wp\/v2\/comments?post=63"}],"version-history":[{"count":1,"href":"https:\/\/www.kernelio.com\/blog\/wp-json\/wp\/v2\/posts\/63\/revisions"}],"predecessor-version":[{"id":64,"href":"https:\/\/www.kernelio.com\/blog\/wp-json\/wp\/v2\/posts\/63\/revisions\/64"}],"wp:attachment":[{"href":"https:\/\/www.kernelio.com\/blog\/wp-json\/wp\/v2\/media?parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kernelio.com\/blog\/wp-json\/wp\/v2\/categories?post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kernelio.com\/blog\/wp-json\/wp\/v2\/tags?post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}