S
S
Sergey Bard2018-07-06 10:01:30
MySQL
Sergey Bard, 2018-07-06 10:01:30

What is the best way to store data in mysql?

Hello everyone, I continue the series of questions on how to do it better), there are projects for which every day the system pulls data from different services, for example, from analytics, I made such a table for generating a request, which has key and value, in value I put json with the necessary variables, then I take it and form a request already, and in the key the name of the request, for example, to know how to process json from value, such a universal solution, if for example you need to make requests for different reports, etc., I just take the fields which fit the desired script by key, so I don’t know how best to save the data, for saving there is a separate table in which there are also key and value fields, in key I save the name of the metric here, and in value the value, so I thought maybe it would be better if the table also saves in json in the value field?,thus, if earlier, for example, from one request there were several lines in the database, now there is one in json, I find the necessary fields in other fields, I mean that I don’t need a search inside json here, tell me what do you think is better to leave it as it is or do it saving in json, I use mysql database

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Entelis, 2018-07-06
@serg_small_developer

If you are 146% sure that you don’t need to search by data - storing json is quite appropriate, though then it’s not clear why there is sql at all.
If there is a chance that you still need to search by data (and in the case of analytics tables, the probability of this is huge) - it is better to create a separate table for each service and save the data in a normal structure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question