E
E
Evgenii Kaidashov2015-09-17 12:51:15
PHP
Evgenii Kaidashov, 2015-09-17 12:51:15

Should I make a separate table for settings?

Hello. There is a table of categories to which the product will later be attached. The category will have a separate landing page with its products, each category can have different images on the background and a couple of additional individual fields. How to proceed in such cases? There is an option to make a separate setting table in which to specify the category id and store all additional fields with type (text, image), name (background, icon) and value.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Pavlenko, 2015-09-17
@Evgenii-Kaidashov

This will be a good solution, but you need to think carefully about how to store the fields with information. Create additional columns for each (a table with columns like id_category background image_url hello_text link_to_buy at_page, etc.)
Or store them in JSON containers (this is worse, but sometimes you can’t do without it). And if the settings from a category to a category are very different, you can generally create an
id_category key value
and only then look for the settings using
+ if you need settings for the whole category at once -

SELECT `value` FROM category_settings WHERE id_category=1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question