Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to reduce number of reads in order to get Question's detail from QuestionCollection (Array of Questions) .

My app works like a part of stackoverflow.

I want to show how many likes, views and comments do a question have . So in order to handle this I created multiple collection like

QuestionCollection

  • ID
  • Title
  • DateCreated

CommentCollection

  • ID
  • Comment
  • DateCreated

QuestionLikes

  • QuestionID
  • UserID

QuestionViews

  • QuestionID
  • UserID

QuestionTAG

  • QuestionID
  • TagID

I thought that CommentCollection (comments) only belongs to a question. So I am thinking of incorporating in QuestionCollection like an array(s) or collection(But it requires another read hit). which one is better ?

And I think of adding two variable's(totalViews,totalLikes) to QuestionCollection. But each time I must have to check whether this question is liked by this user or view by this user.

Give me a suggestion or an alternative so I can have the least hit to fetch question details.

Edit

For Showing View Count I iterate and count QuestionViews Collection where questionID == myQuestionID

For Showing Likes Count I iterate and count QuestionLikes Collection where questionID == myQuestionID

why I don't add it to QuestionCollection? Because I want to show most Viewed and most like question like stackoverflow. If i add it to QuestionCollection How could I know the most like and most Viewed question.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
216 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...