简体   繁体   中英

Best approach to user activity wall

I have different post types, like status updates, projects, donation etc. Each type of post has its one or more tables in databse. A user can create all post types. User has a wall like Facebook where he can see different post types which he created in chronological order (any post type created last should be on top of the wall).

What would be the most appropriate approach?

  1. Fetch data from database with different queries store in array and then manipulate array?
  2. To write a complex single query which can fetch data from different tables in chronological order?
  3. To make a separate table for user activity and store data whenever user perform any activity?
  4. Your approach different from the above?
  1. simple to set up, doesn't perform very well (has a very bad worst-case).

  2. is the simplest. You say complex but you can do this fairly easy with a UNION + ORDER BY construction. Performance will be pretty good.

  3. will perform the best I think but there will be some duplication and things might get a little complex. Relational databases are not very good at polymorphism.

What's important to realize is that it's relatively easy to switch between these solutions. If you have a service oriented architecture (or just good design in general). So I wouldn't be too worried about which approach you pick. If in the future it seems your chosen approach doesn't work too well you could switch to another.

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