M
M
MVP_Master2021-01-22 13:38:07
Database design
MVP_Master, 2021-01-22 13:38:07

Where is the best place to store a frequently changed field? in the general table of goods or separately?

There are a lot of fields in the product table. These fields are usually changed by the operator and not so often.
Now we need to add the "number of views" field, which will change each time the product is viewed.
Should I add this field directly to the product table, or is it better to create a related table with a
one-to-one relationship? and to change in that table? Which would be better from a design point of view?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Korotenko, 2021-01-22
@firedragon

I would store it in the cache and drop it into the database only when updating. Well, choose the cache yourself, either you just have a structure, or a radish, or something else

Y
Yerlan Ibraev, 2021-01-22
@mad_nazgul

IMHO the number of views has nothing to do with the essence of the product.
It's more of a monitoring thing.
So it makes sense in general to take this logic out of the database.
To some key-value store.

A
Andrey Skorzhinsky, 2021-01-23
@AndyKorg

Separate the essence of the product, from the essence of "browsing history" is the best. In essence, "browsing history" in addition to the product index store the date of viewing. Almost 100% managers will want to keep track of all sorts of bursts of views and other analytics. To begin with, you can shove everything into one table, as you grow, you will have to separate the archive logs (for example, for a year) from the operational ones.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question