title: Dynamic columns in mysql tables?
body: <p>I want to add dynamic columns in a mysql table but I don't know exactly how.</p>
  
  <p>I want to let the user add some columns (fields) in a thread, eg. let him add a integer field and a value (eg. price: 199) or a string field and a value (eg. name: teddybear).</p>
  
  <p>The user can add as many field/value-pairs as he wants.</p>
  
  <p>I thought I could create a many-to-many table:</p>
  
  <p>thread &lt;-> thread_field &lt;-> field</p>
  
  <pre><code>thread: id, title
  thread_field: field_id, thread_id, value
  field: id, name
  </code></pre>
  
  <p>is this a good structure?</p>
  
  <p>But in this way I have to set a specific column type of thread_field.value. either it's an integer or a string. I want to have the possibility to have it dynamic, let the user choose.</p>
  
  <p>How can I do this?</p>
  
  <p>Thanks!</p>