针对特定场景的数据库用户表设计 [英] Database user table design, for specific scenario

查看:54
本文介绍了针对特定场景的数据库用户表设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已被问过很多次,并且已经花了很多时间阅读以下问题:

I know this question has been asked and answered many times, and I've spent a decent amount of time reading through the following questions:

问题在于,对于几类解决方案,支持者的分布似乎有些均匀:

The problem is that there seem to be a somewhat even distribution of supporters for a few classes of solutions:

  • 只要规范化,就将用户设置停留在单个表中
  • 将其拆分为两个1到1的表,例如"users"和"user_settings"
  • 使用某种键值系统对其进行概括
  • 以位域或其他序列化形式粘贴设置标志

所以冒着重复问题的风险,我想描述一下我的具体情况,并希望能得到更具体的答案.

So at the risk of asking a duplicate question, I'd like to describe my specific scenario, and hopefully get a more specific answer.

  • 当前我的站点在mysql中有一个用户表,大约有10-15列(ID,名称,电子邮件,密码...)

  • Currently my site has a single user table in mysql, with around 10-15 columns(id, name, email, password...)

我想添加一组针对每个用户的设置,用于是否针对不同类型的事件(notify_if_user_follows_me,notify_if_user_messages_me,notify_when_friend_posts_new_stuff ...)发送电子邮件警报.

I'd like to add a set of per-user settings for whether to send email alerts for different types of events (notify_if_user_follows_me, notify_if_user_messages_me, notify_when_friend_posts_new_stuff...)

我希望将来我很少会为每位用户添加一个关闭的设置,这些设置通常与用户之间是1:1.

I anticipate that in the future I'd be infrequently adding one off per-user settings which are mostly 1 to 1 with users.

我倾向于创建第二个user_settings表,并在其中粘贴诸如电子邮件通知设置之类的非必要"信息,以保持主用户表的可读性,但我非常想听到期望的内容说.

I'm leaning towards creating a second user_settings table and stick "non-essential" information such as email notification settings there, for the sake of keeping the main user table more readable, but is very curious to hear what expects have to say.

推荐答案

似乎您面临的难题是是否垂直划分用户表.您可能需要阅读

Seems that your dilemma is to vertically partition the user table or not. You may want to read this SO Q/A too.

这篇关于针对特定场景的数据库用户表设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆