Suppose if you need to store a dynamic set of parameters, options, whatever, attached to one entity, which approach would be better for this ?. These options come to mind:

  1. serialize ()
  2. json_encode ()
  3. create a table to store the type of the parameter and associate it with the required entity through an intermediate table
  4. something I didn't think of

It is very interesting to hear opinions, which of the approaches is better and why.

  • if the search and retrieval by means of a DBMS is necessary, then the first and the second one by. - teran
  • Yes, a fair comment, but I would like to know which option is generally more logical to use. In practice, met with the first and was not thrilled - theHolyGranade
  • You have not voiced the most important thing - what exactly will be done with this data. And just keep - do not care how, if only without loss. - Akina
  • one
    In practice, you need to use one that fits specifically for your task. And to determine this it is necessary to provide the entire possible set, at least frequent requests to this database. What do you do with the data more often, look for specific attributes, add new data, update old ones with an impact on the minimum of attributes, choose one object with all attributes, choose a set of objects with all (most) attributes. In extreme cases, it is even possible to store data in EAV, as well as their copies in serialized (as either json) form. - Mike
  • And the question is whether your version of MySQL supports direct operations with json - Mike

0