The recipe for a good Data Model on Magento 2 - Part 2
by: Kévin Weyhaupt
Part 2 : Adding Flavour
At the moment we only have the business-class-model part, we need to add the relation with our datas. To do so, we will create our “resource models”. The resource models enable to link our models with the data base. Here the classes inherite from AbstractDb in order to accomplish some operations before or after different actions on the database, for instance « after/beforeDelete», « after/beforeSave » but above all to define in the constructor the table and the primary key related to our object using the “_init” method.