mysqldatabaseinheritancedata-modelingclass-table-inheritance

How to map OO inheritence to a relational database scheme?


I have a canonical data model. Some fields are related to the pricing of a product. It inherits certain attributes from the product table. I want to model this inheritance in a MySQL relational database. How can we model object-oriented inheritance in a relational database scheme?


Solution

  • Martin Fowler discusses this extensively in his book Patterns of Enterprise Application Architecture book. Get this book and look into:

    1. Single Table Inheritance

    Blockquote

    1. Class Table Inheritance

    enter image description here

    1. Concrete Table Inheritance

    Blockquote

    The Website should give you some idea. You might also want to read the section on inheritance mappers. Each of the different approaches have their pros and cons so choose wisely.