我应该为社交网络数据库的用户及其个人资料创建单独的表吗?
我想为社交网络设计一个数据库,为用户提供个人资料。我应该为用户及其个人资料使用单独的表,还是只为用户及其所有属性使用一张表?
I want to design a database for a social network which will provide profiles for users. Should I use separate tables for users and their profiles or just one table for users and all attributes in it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果你想做大,那就为用户单独做一个。
用户和属性同表的优点:
单独表的优点:
If you want to go big, then do a separate one for the users.
Advantage of users and attributes in same table:
Advantage of separate tables:
如果您打算使用关系数据库,我会推荐一个单独的表(规范化、外键等)。
如果您有兴趣尝试其中一种文档存储数据库(例如 MongoDB、CouchDB、RavenDB),那么我会首先考虑访问用户时是否正常访问属性。如果是这样,那么您应该将属性作为嵌入文档放置在用户内部。
祝你好运!
If you're going to use a relational database, I would recommend a separate table (normalized, foreign-keys, etc.)
If you are interested in trying one of the document-store databases (e.g., MongoDB, CouchDB, RavenDB), then I would consider first if you normally access attributes when you access a user. If so, then you should place the attributes inside the user as embedded documents.
Good luck!
将它们分开,用户和配置文件松散耦合从长远来看会很有帮助。个人资料可以是社区、群组的,而不仅仅是用户的,所以我建议将它们分开。
Keep them separate, Users and Profiles loosely coupled would be helpful in the long run. Profiles can be of communities, groups too not just users, so I suggest keeping them separate.