Database table structure for user settings

▼魔方 西西 提交于 2019-12-03 21:58:59

问题


I need to add a table to store user settings. For the first time users will have about 10 different settings, but I'm sure there will be more.

What scalable structure of database table to store user settings would you suggest?

Any help would be greatly appreciated.

Thank you!


回答1:


Settings table columns -: setting_id | setting_code | setting_name | setting_description

User table columns -: user_id | user_name | user_password | etcetera

User-settings table columns -: user_setting_id | user_id_fk | setting_code_fk | setting_value

structure like so:

Users --> User Settings <---- Settings

Hope this helps.




回答2:


Depends on the settings.
If it's just flags, you can use bit mask.

If it's strings - just make separate fields.
Do not make it "scalable". Databases must be scalable in length (and they are), not in width.
Just plan your database structure before starting a code.

If it will be poor plan - OK, you can add a few fields later. But do not make it on regular basis. It's a sign of poor database design.



来源:https://stackoverflow.com/questions/2974321/database-table-structure-for-user-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!