简体   繁体   中英

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...).

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.

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 ?

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. 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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