Storing a large number of user settings
I'm working on a web app, and I'm in the process of adding a user authentication system (probably just going to go with FB/Google auth) so that users can save settings (and possibly progress) with the app. The problem is that there are going to be upwards of 150+ different user settings. I'm planning to use a MySQL database to store user data, and I've heard plenty of times that you never ever store multiple data items in one column, so using a 150+ column table really doesn't seem like the best way to go about doing this. Would two tables, one for basic user info and another for generic "settings" items (name, value, user_id [foreign key]) be a good way to handle this? Or is there a better approach for storing/retrieving large amounts of user data?
The project in question is a web based hiragana/katakana flash card app, and I'm planning to allow users to choose which kana are displayed (along with several other settings, mostly boolean).
Thanks!
Posted Jun 12, 2014, 9:57 PM UTC
Bools can be compressed with bitmasking, I'd best let wikipedia explain, At a previous company we had a ton of bools that we saved as bytes in DB and used them as a bit array in the program. However I'm no DBA and your performance may change, try before you buy :) BTW you state you don't want 150+ columns, do you want 150+ rows per user then? ;) I think something like table users(..., bool_settings BINARY(255)) would suffice.
Well, ideally not, but that seemed like the better of the two options. I like the bit array idea, though. I think I might go with that (pending some more research). Thanks!