D
D
Dmitry2020-11-24 00:38:35
MySQL
Dmitry, 2020-11-24 00:38:35

What is the best way to organize the storage of multiple text data?

Good day. Puzzled to update a project that I did 5 years ago, even before learning the zen of (crossed out) laravel. I spent a day threatening to solve the quest what from where and how much, as a result, I spat and decided to do everything again with the existing skills. There are branches of the company. Connections branch-employee, branch-schedule, branch-events are made. Normal adequate models and connections. Branch and load the necessary data to it. Everything is working.
But there is a mainpage table. I look at its structure and am horrified.

29 text fields a la zagolovok_main about_branch etc.
Total 6 lines by the number of branches and 29 fields.

How to make a model of such a "field" and register a binding to the city?

In one of the microprojects, I used the qcod/laravel-settings package like. In general, storage is based on the key/value principle.

Am I correct in my reasoning that it is better for me to make a table / model with all these fields (29 lines).

And already through the key / value to fill in the data
Branch_id key value

I understand that this is one of the basic questions, but still?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Vorotnev, 2020-12-03
@HeadOnFire

Well, it's essentially the metadata for the branch model. IMHO, there are 3 options:
- store all this metadata in one field in the branch table, in the form of JSON
- store data in a separate table, structured - with columns for all these metadata
- store data in a separate table long and skinny - in the form of id | branch_id | key | value
As for me, the structured table here is an overkill. The metadata table is a subjective thing. Some people like it, some don't. JSON - modern, fashionable, youth. In PostgreSQL it's native and fast, in MariaDB it's almost native and almost as fast, in MySQL xs, I haven't looked in a long time. I think it should have been decided.

D
Dmitry, 2020-12-03
@dlnsk

If these 29 fields are connected with branches, can some of them be transferred to the appropriate tables?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question