There is the following data structure
Школа - Количество учеников - Класс - Количество учеников в классе Школа - Количество учеников - Класс - Количество учеников в классе - Класс - Количество учеников в классе At the same time, in the process of using the database, it is necessary to do sampling by the value of "Number of students", and sampling by classes is not required, moreover, data on classes is always used for each of the schools as a whole. I.e
Школа - Количество учеников // ****************************** // Начало единой структуры данных - Класс - Количество учеников в классе - Класс - Количество учеников в классе - Класс - Количество учеников в классе // Конец единой структуры данных // ****************************** There are two possible options:
- Create a separate table for classes.
- Create a single field for classes and put data there in a special format, for example, JSON.
In the second case, the base ceases to be relational in its pure form, but the schema is simplified and data access is accelerated (less SQL is needed).
What are the pros and cons of the two approaches possible?
That is, it was
таблица Школы таблица Классы It became
таблица Школы Where there is a Classes column containing JSON, which for each school now stores the data that was previously in the Classes table.