T
T
tvsjke2018-02-26 20:01:27
MySQL
tvsjke, 2018-02-26 20:01:27

How to properly store an array of user settings?

Hello.
Initial data:
There is an online store on Laravel (but this, in theory, is not important). And each user has settings in their personal account. There may be several levels of nesting. Settings are needed for the user notification system.
5a943a9173cbb302149491.png
They need to be stored and be able to work effectively with them. For example, it should be possible to quickly get all users who have an alert selected.
I made tables settings (name, id_parent) and setting_user (user_id, setting_id, value).
I can't explain why, but I don't like this option. Create two tables for some unfortunate settings?
Maybe just add a field with the json type to users and store all the settings there? But how then to make selections by settings with different conditions?
In general, I ask you for ideas for implementing efficient storage and use of these settings.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2018-02-26
@tvsjke

MySQL 5.7.8 and newer can query the contents of json fields.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question