dymanic columns in mysql tables?
- by fayer
i want to add dynamic columns in a mysql table.
but i dont 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 its an integer or a string. i want to have the possibility to have it dymanic, let the user choose.
how can i do this?
thanks!