简体   繁体   English

创建博客数据库

[英]Creating a blog database

I am trying to create a blogging sites. 我正在尝试创建一个博客网站。 My problem is how to handle the blog database system. 我的问题是如何处理博客数据库系统。

For example , i have a scenario like for each blog there may have more comments,likes,photos,videos for one blog. 例如,我有一个场景,每个博客可能有更多评论,喜欢,照片,视频。 so i created separate table for comment,likes,photos,videos and insert each record with related blog id (ex : one blog can have more than one photos,comments ,videos...). 因此,我为注释,喜欢,照片,视频创建了单独的表格,并插入具有相关博客ID的每条记录(例如:一个博客可以包含多个照片,评论,视频...)。

But the problem i am facing really when i am trying to create a summary of the blog by creating a view for blog with related tables. 但是,当我尝试通过为具有相关表的博客创建视图来创建博客摘要时,确实遇到了问题。 The blog view has duplicates when i joining blog table with comments,likes,videos tables using blog id. 当我使用博客ID加入带有评论,顶,视频表的博客表时,博客视图重复。

Please help me on this ? 请帮我吗? can anyone suggest any idea for handling this problem or can anyone would know how fb or twitter handle this situation ? 谁能提出解决此问题的任何想法,或者有人会知道fb或twitter如何处理这种情况?

please correct me if am wrong i ready to redesign the database if anyone has new idea ... 如果错误,请纠正我,如果有人有新想法,我准备重新设计数据库...

It would be great if you help me on this.I am struggling to find the way for this ... 如果您对此有所帮助,那就太好了。我正在努力寻找解决方法...

Can anyone share me a example . 谁能给我一个例子。

What you need is to build aggregation mechanism. 您需要建立聚合机制。 After you read from SQL view this mechanism should compose those multiple rows that were produced with LEFT JOINS into object that fits you needs. 从SQL视图中读取后,此机制应将用LEFT JOINS生成的那些多行组合成适合您需要的对象。 It most likely will have arrays for photos and other join-able data. 它很可能将具有用于照片和其他可连接数据的数组。

Here's an article that is showing how to create such an object. 这是一篇文章,显示了如何创建这样的对象。
Database results as objects or arrays? 数据库结果是对象还是数组?

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

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