title: Handling table attributes/properties using CakePHP and MySQL
body: <p>First of all, happy new year :-)</p>
  
  <p>I think my question would be obvious for good programmers but I didn't manage to find an answer.</p>
  
  <p>Let's say I have a <strong><code>Customer</code></strong> table and I would like this Customer to have some attributes (properties). I don't want to add a new field in the Customer table every time I will add a new attribute. Moreover, customers don't have the same number of attributes.</p>
  
  <p>All that we know is each attributes is known in advance (some day, I will add a 'referer', 'age', 'type_of_prefered_food' ....  attributes that is not mandatory, so customers may fill the information or not).</p>
  
  <p><strong>My question is, which is the best way to manage it using CakePHP 3 and MySQL ?</strong></p>
  
  <p>Having a <code>Customer</code> HasMany <code>Attributes</code> (If think in this case I have to have a constant list of each properties ID)</p>
  
  <p><strong>OR</strong></p>
  
  <p>Having a <code>Customer</code> BelongsToMany <code>Attributes</code> (so, through a relation table)</p>
  
  <p>Knowing that, which is the best :
  Having a attribute ID referenced by an INTEGER or a STRING ?
  How to retrieve a specific property ...</p>
  
  <p>My question is mostly CakePHP oriented, I want to know if one approach is easier to work with. Is there a CakePHP Tools/function/library that will help me to retrieve/add/edit easily attributes to a specific Customer ?</p>
  
  <p>The best question I managed to find is : <a href="https://stackoverflow.com/questions/649802/how-to-pivot-a-mysql-entity-attribute-value-schema">How to pivot a MySQL entity-attribute-value schema</a></p>
  
  <p>Thanks in advance for those having the time to respond.</p>