开发者

databases design

for example i have table users, which have 3 fields:

id - lo开发者_如何转开发gin - password
---------------------
1  | john   |  *****
2  | jack   |  *****
3  | jane   |  *****

now i want that each user could have his own settings. So, do i need to create three different tables, like

user_N_settings:

id |  key        | value
-------------------------
1  | save_data   | True

or i should create one big table for all users instead?

users_settings:

id     | key       |    value   |    user_id
---------------------------------------------
1      | save_data |   True     |        2
2      | some_opt  |   False    |        3


One table for all users. A table per user would be very wrong.


One table. If all the setting values are of the same type then it may make sense to create one row per setting. If the attributes are all very different then create one column per setting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜