I want to add dynamic columns in a mysql table but I don't know exactly how.
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).
The user can add as many field/value-pairs as he wants.
I thought I could create a many-to-many table:
thread <-> thread_field <-> field
thread: id, title
thread_field: field_id, thread_id, value
field: id, name
is this a good structure?
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.
How can I do this?
Thanks!