表设计中遇到的多对多的关系解决方案 (zt)


比如:

有4个表user,article,mark,act,许多生手开始时都会这么设计:
user : user_id, act_id, user_name, user_password;
article(文章): article_id, article_content, author_id, article_publicTime;
mark(评论): mark_id, author_id, mark_time, mark_content, article_id;
act(角色): act_id, act_name;
这样显然有问题,表user中会有许多冗余数据.对于user和act的这种多对多的关系,一般都可以拆成一对多的关系,方法就是加一个关系表:

表user : user_id, user_name, user_password;
表act(角色): act_id, act_name;
用户和角色的关系表 user_act:user_id,act_id 

就这么简单。
来自:饮马流花河

原文地址:https://www.cnblogs.com/wt0731/p/926204.html