D
D
Dmitry Larin2018-12-13 16:31:45
PHP
Dmitry Larin, 2018-12-13 16:31:45

What is the best (cheapest) way to store directories?

Please resolve the question - in what form is it better to store directories.
Let's say we have such a horse in a vacuum - an online store (on yii if it's important) with 1c integration, from where all the data is pulled up, incl. reference books of colors, sizes, manufacturers, etc., etc. So what's the best and cheapest way to store it? To get under each directory the separate table? Keep everything in one? Or store directories in the form of xml (json - depends on religion) files, and read them if necessary? Which method is cheaper in terms of RAM/CPU? Let's say we still have a small highload in the form of 10k+ hits per day.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2018-12-13
@leahch

10k per second, it's normal - this is a highload, and a day - nothing at all ~ 7 requests per minute
Starting a separate table for each directory is the way towards Bitrix and the grave.
Store in xml / json - why, if there is a database.
It seems to me that a separate table id|name|value|type is enough, well, a couple of tables, one more with a description.
Well, cache all this in redis. Read everything at startup and load into it.

T
thyratr0n, 2018-12-14
@thyratr0n

I see people are getting carried away with normalization here. Let me explain: there are 6 forms of normalization, but there is a harsh reality. Dot. And there is nothing to point out about any violations against Alexei Cheremisin .
Handbooks should be stored as much as possible. If the data is of the same type:
1) if the data in them is of the same type, you can throw everything into one table by washing down the composite RK (type, key) or the old-fashioned single one - this is whatever you like (as long as the number of records is no more than 6 digits, the differences will not);
2) you can file the same thing in different tables - for taste and color, as he says.
If the data is of different types, then:
1) it is possible in different tables, if filtering can be done on different fields;
2) everything is possible in one table, having washed down some "complex" field with the TEXT / BLOB / VARCHAR type, where to write different data.
Everything, there is no smell of normalization here. All good.
PS Dmitry Larin , you should formulate your questions more precisely, because "Without TK, the result is XZ" (c)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question