I have seen two different approaches in saving user preferences.
APPROACH 1: Serializing them and saving in one of the column of USERS table
APPROACH 2: Creating a separate table PREFERENCES and make a has_many association from USERS to PREFERENCES.
Which one of the above two approaches would you prefer and what are the pros and cons of each over other?
Usually to store user preferences, it is best to use localStorage.
To specify settings that can be customized for a particular user, configure user preferences. A set of DefaultPreferences is assigned to each user of the Cúram application. A user preferences editor is available in the web client. This editor allows each user to update values for the preferences.
It's usually a good idea to favor normalization. The second solution keeps your models cleaner, allows for easy extensibility if new preferences are added, and keeps your tables uncluttered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With