Answer the question
In order to leave comments, you need to log in
How to organize the structure of database tables?
It is necessary to store information about the interaction of the user with the object in the database. Among the characteristics of the session, there are two parameters: the duration of the session and the elements of the object involved. The proposed structure is as follows:
The sessions
table The elements
table The linking table session_elements
Everything seems to be fine, but there will be too many sessions (80k-100k per month) and elements (10k-20k). Thus, the link table will grow even faster in the calculation that one session will have an average of 5-10 elements. The main queries will look like:
SELECT * FROM `sessions` WHERE `duration` > 100 AND EXIST (SELECT * FROM `session_elements` WHERE `session_id` = 1 AND `element_id` = 1)
Answer the question
In order to leave comments, you need to log in
Let's count. 2 ints per session (8 bytes) 100,000 times a month is 800kb. Plus elements, let's say 20 bytes per line and 4 bytes per int in the amount of 20,000 - this is 192kb. Total 1 megabyte per month. 12 mb per year.
My conclusion: put a couple of GB on the server. memory for 500 rubles and forget about the problems of the next 170 years.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question