K
K
KirSupi2021-07-04 17:04:10
Database design
KirSupi, 2021-07-04 17:04:10

How would you recommend storing the data?

The task is as follows:
A normal MySQL database on a regular hosting
There are a certain number of users (> 200)
Each user has

some data

# пример данных:
"user10" : {
    "way": 15,
    "trees": 10,
    "songs": 7
}

Moreover, all this must be cached by dates, i.e. you need to store the data of a specific user on a specific day, so that if necessary you can pull them out for a php / python
script Backend and never really worked on the database, so nothing better comes to mind than creating a cached_data table in the database and two columns in it - date and data, and in date write, for example, "2021-07-04", and in data write json with all the data of all users.
Can you advise how it would be easier and more convenient to store all this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2021-07-04
@hint000

Pushing json inside SQL is a game; choose either one or the other.
If the field names are not fixed, then like this:
date user var val
--------------------------------
2021-07-04 user10 way 15
2021-07-04 user10 trees 10
2021-07-04 user10 songs 7
https://en.wikipedia.org/wiki/Entity%E2%80%93attri...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question