S
S
SoloMidPlz2015-12-25 14:31:03
MySQL
SoloMidPlz, 2015-12-25 14:31:03

User Settings Database Design/Scheme?

How are user settings saved now? Despite the fact that over time, the service may need additional. settings.
I know a few options in theory
1) just create new settings as columns of the users table or user_settings table
2) create two additional tables
settings
id name
user_settings
id user_id settings_id value
(typical case)
3) create a settings column in the users table and shove the settings text there (json or just vars)
4) for each user to create a settings file in a non-public folder.
I don't know why, but I like the 3rd option the most, but I'm already tired of doing it for myself. I want to do like people)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2015-12-25
@SoloMidPlz

0 [intro] )
not quite the right strategy for a developer. You need to look at how people do, feel what you understood and liked, and then do the same for yourself. Within the framework of this question, no one will tell you better than you how you need to.
Now, to the point:
1) an option suitable for the case of up to 5-6 settings per user, and with confidence that their number will not grow; if more - not worth it;
2) it's EAV. I don’t really see the point in it if item 3 is available to you;
3) json-column settings is nothing to itself. An important advantage is that you can then only store user overridden values. And as a rule, users do not change more than 20% of the settings, especially if they are well chosen. Those. after creation, you will have an empty json object, and after each setting change, a field will be added to the object if the setting has not yet been changed, or updated, or deleted if the user clicked "reset to defaults". In the case of point 1, you would have to use NULL to mark that the user did not set this setting;
4) I don’t see much point: the settings files will probably be small, plus these files will be in your list, not a hierarchy, and then it makes sense to use a file system;
and 5 more) if the project is large and there are a lot of settings and users, I would think about using a document database for this purpose - then it will be possible to allocate a separate service for the task of storing settings.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question