Answer the question
In order to leave comments, you need to log in
What is the best way to implement additional fields?
I am writing "CMS" on laravel 5.2, for future projects, and there was a question about additional fields for added publications. Additional fields will have types: numeric, text, drop-down list, date, template, etc.
The idea of implementation is this: Tables:
Answer the question
In order to leave comments, you need to log in
P.s. Пока все описывал, понял, что довольно глупый вопрос :)
I am also studying this issue, and so far I see that the most optimal implementation option is like this (such as infoblocks in Bitrix or information systems in HostCMS).
We have the following tables:
1) The records themselves (id|...|category_id)
2) Categories (like id|parent_id|customfields_table)
3) A set of custom fields for the category (id|custom_1|custom_2|...)
4) Description of custom fields for the table of custom fields (custom_{id}|type|name|slug|...)
Something like this, everything is normalized and connected, in my example, sets of custom fields are tied to categories, as in JBZoo or in HostCMS, but in this In the same style, you can bind them to other entities, like infoblocks in Bitrix, but these infoblocks are also associated with categories (well, then the logic already depends on the tasks).
Are there any other considerations?
PS And the question is interesting and not at all stupid.
The main question is how often the table changes, how much extra is planned. fields. and to what extent do all rows have these fields?
Those. example:
if there is a field that 1 out of 1000 records has, then it makes sense to put it in a separate table.
The same fields as "date of creation", "author's number" and so on, it makes sense to store in the main table publications.
It may not be a completely normalized table, but it's more practical :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question