mercredi 10 mai 2017

How to model concrete table relationship where a child entity is different for different product types?

I am thinking of using Concrete Table Inheritance for a use case, and need help determining if I need to use identifying vs non-identifying relationship, and also if how to structure my tables exactly.

My use case

I have an HTML form object where the form is the same mostly for many things, i.e. it is a large form that is identical for different products, except for product_options, which are different depending on exact product_type. I want to save form data into tables, for storage/retrieval. I think I want to use Concrete Table implementation, and need feedback on if that's the way to do it.

Here is what I am thinking:

enter image description here

Say if I want to retrieve information for product of type "A", I

  1. Read selection_for, retrieve product_type
  2. Based on product_type I read the appropriate options table

This seems to be a bit complicated...

I am also using Doctrine ORM to drive the database behind the scenes, so such data manipulation may prove to be difficult to implement via ORM API, but I wanted to consider this option first.

Questions:

  • Will my design work as-is? Can it be improved upon? Did I implement Concrete Table design correctly?
  • Do I use identifying or non-identifying relationship for the product option tables?

I can also do an alternative diagram like so:

enter image description here

But it is not clear to me if there are any pros or cons to that methods compared to the first one.

Aucun commentaire:

Enregistrer un commentaire