简体   繁体   English

社交媒体数据库设计:是否应该创建以用户为中心的表格? 还是具有相关数据的主表?

[英]Social Media Database Design: Should user-centric tables be created? Or master tables with the relevant data?

I'm trying to understand, conceptually, the design of a social media site. 我试图从概念上理解社交媒体网站的设计。 I've seen on Database Answers that a sample model has a "Me" table, myMovements, myProfiles which I assume are unique to the user (ie, user Bob has: Bob, bobMovements, bobProfile). 我在数据库答案中看到一个示例模型具有一个“ Me”表,myMovements,myProfiles,我认为它们对用户是唯一的(即,用户Bob具有:Bob,bobMovements,bobProfile)。 But then there are tables such as "Contacts" and "Wall_posts". 但是,还有诸如“联系人”和“ Wall_posts”之类的表。 In this case, are we saying it's fine to put all users' contacts or wall posts into one table and then run a query to select by user_id (I presume this is done to prevent several empty tables that aren't really being used)? 在这种情况下,我们是否说可以将所有用户的联系人或留言张贴到一个表中,然后运行查询以按user_id进行选择(我想这样做是为了防止几个未真正使用的空表)? Or would those tables be created separately as "Bob_wall_posts"? 还是将这些表分别创建为“ Bob_wall_posts”?

Being new to database design, I'm curious as to what type of performance differences (if any) would there be going one way or another; 作为数据库设计的新手,我很好奇哪种性能差异(如果有)会以一种或另一种方式出现。 and would there ever be a reason to create "bob_wall_posts" as that would seem like a nightmare to manage? 并且是否有理由创建“ bob_wall_posts”,因为这似乎是一场噩梦般的管理?

With that being said if say the contacts table has millions of records as a table like that will grow exponentially, is there a way to build it to optimize performance? 话虽这么说,如果说contacts表具有数百万条记录,因为这样的表将成倍增长,有没有一种方法可以构建它来优化性能? Or some method of writing an optimized query? 还是一些编写优化查询的方法?

Below is the model I was referring to. 以下是我所指的模型。

社交媒体模型

Fundamental to relational database design, You would simply not be building data tables for each user... 关系数据库设计的基础,您根本就不会为每个用户建立数据表...

I don't even think performance issues should be addressed, it's just not done... 我什至不认为应该解决性能问题,只是没有完成...

Relational databases have pretty fast search optimisation. 关系数据库的搜索优化非常快。 Just define your keys properly, and use indexes where required and you should be good to go... 只需正确定义键,并在需要的地方使用索引,就可以了。

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM