V
V
Veiwai2021-09-13 20:22:33
Database design
Veiwai, 2021-09-13 20:22:33

How to organize the storage of views?

Hello everyone, I'm learning backend and databases. I am making a small blog, please share your practice, how to organize the storage of views for posts?

For views, create a separate table and store each view, or store views directly in the post record, as a number and increase it by +1

. What options are there and which is better to use?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jazzus, 2021-09-13
@jazzus

Table of polymorphic connection with view objects and field increment in the posts table. The views table will help build logic, for example, count no more than one view from a user for a post in half an hour, etc. You can display statistics with filtering, for example, for the authors of the post who watched when or clear the table with cron once a day. There are many options, the implementation depends on the requirements.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question