I have four types of products that I would like to map to the Doctrine ORM structure on MySQL DBMS. Products PrepaidProduct , PostpaidProduct , MobilePrepaidProduct , MobilePostpaidProduct with the following structure:
abstract class Product { private $price; ... } class PrepaidProduct extends Product { private $credit; private $prepaidDiscounts; } class PostpaidProduct extends Product { private $bundleMappings; } class MobilePrepaidProduct extends PrepaidProduct { private $device; } class MobilePostpaidProduct extends PostpaidProduct { private $device; }
The main idea is that I would like to use a service (factory) that will use the base structure of the class of the PostpaidProduct class to create the structure of the corresponding bundle mapping, so I think I will need this as a mapped superclass.
In my opinion, the way to use it will be to have two separate tables: one for PostpaidProduct and one for PrepaidProduct , as well as one-page inheritance for those for MobilePostpaidProduct / PostpaidProduct and MobilePrepaidProduct / PrepaidProduct .
What do you guys think? Any thoughts on the best way to model this?
source share