为带有评论的照片库创建数据库
我正在创建一个社交网络,希望有一个与 Facebook 类似的照片库。我猜我需要使用 AJAX,但我希望每张照片都有一个评论部分。我只是想知道围绕此设计数据库的最佳方法是什么。我只是做一个评论表吗?我会遇到性能问题吗,因为我确信每个用户都会有不止一张照片,因此内容表会变得相当大。假设我有 1000 万用户,每个用户有 100 张照片,每张照片有两条评论,那么这将是 20 亿个条目,而这只有 1000 万用户,如果这个数字增长会发生什么。这会大大减慢网站速度。我知道现在我可以开发一些简单的东西,比如一张桌子,但我想快速创建一些东西,并为未来提供知识。如果有人能帮助我解决这个问题,我将不胜感激。
I am creating a social network and want to have a similar photo gallery to that of facebook. Im guessing I need to use AJAX but I would like to have a comments section for each photo. I was just wondering what the best way would be to design a database around this. Do I just make a table of comments? Would I run into performance issues because Im sure each user would have more than one photo, so the contents tables will get pretty large. Supposing I had 10 million users and each had a 100 photos that with two comments each that would be 2 billion entries and that is only 10 million users, what would happen if that number grew. This would greatly slow down the website. I know for now I can just develop something simple like one table but I would like to create something fast and be knowledgeable for the future. If someone could help me out with this I would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有 1000 万用户,您将有钱购买更多资源来处理请求:)
我会设计一个包含评论的表格,另一个用于照片的表格。这两个表当然以一对多关系连接。
一个好的、配置正确的 RDMBS 不会关心存储和选择照片以及评论。这是数据库的工作,不用担心。
If you have 10 million users, you'll have the money to buy more resources to handle the requests :)
I would design a table with the comments, and another for the photos. The two tables are of course joined with a one-to-many relationship.
A good, properly configured, RDMBS won't care to store and select photos along with the comments. That's the db job, don't worry.
选择关联数组,这是大多数社交网站(如 facebook 等)使用的
使用有点像:
go for associative array that's what most of social networking sites like facebook etc use
use somewhat like: