Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best approach to save user preferences? [closed]

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?

like image 763
Dharam Gollapudi Avatar asked Jul 03 '09 14:07

Dharam Gollapudi


People also ask

What is used to store user preferences?

Usually to store user preferences, it is best to use localStorage.

What are user preferences?

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.


1 Answers

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.

like image 161
Pesto Avatar answered Sep 18 '22 12:09

Pesto