Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7856997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:53:24+00:00 2026-06-02T20:53:24+00:00

I am creating an app in which users can make posts and other users

  • 0

I am creating an app in which users can make posts and other users can like and comment over these posts.To achieve this facility i am using tables likes POSTS, LIKES, COMMENTS.(I am using parse.com database to store these table).

POSTS have fields like postId, content, userWhoMadeThePost, dateOfPosting

LIKES contains filelds as id, postOnWhichLikeWasMade (foreign key to POSTS(postId)), userWhoLiked, dateofLike

COMMENTS have id, content, postOnWhichCommentWasMade(foreign key to POSTS(postId)), userWhoCommented, dateOfComment

I want to retrieve most popular posts (posts with most no of likes and comments).

  1. First way to do this is count no of post and likes for each post each time whenever a request is made for popular posts but this can become very time consuming if
    there are millions of posts.
  2. Other way to do this one way is to include ‘noOfLikes’ and ‘noOfComments’ in POSTS table, so in order to get popular posts I will have to access only post table, but the problem with this approach is whenever a user makes a comment over a post then I will have to increment ‘noOfComments’ in POSTS table as well as make a entry in COMMENTS table, problem starts when the increment is successfully made to POST table and before making change to the COMMENTS table connection is lost. In that case POST and COMMENTS table would be showing wrong data.

How to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:53:26+00:00Added an answer on June 2, 2026 at 8:53 pm

    This would be simple, if you had control over the database, but doing this with Parse means that you have two main problems (one of which you already mentioned):

    1. As far as I can tell, Parse does not allow grouping in queries. That means that (with your schema) it’s actually impossible to get the most liked/commented posts without retrieving all of them. This is because you can’t actually dynamically add a new column with the number of likes/comments like you would in a standard SQL query (using JOIN and GROUP BY).
    2. You can’t update more than one object within one transaction, so there is the possibility that a user could add a comment but the number of comments in the post object would not change.

    That being said I think (at least if you insist on using parse) you must add the ‘noOfLikes’ and ‘noOfComments’ columns to the Post object. Not only does it provide the only viable solution for retrieving N top posts (without getting all of them), but the actual risk of inconsistencies is pretty low in my opinion. You can always catch network (or other) exceptions and temporarely store the update requests locally and retry them later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a news app which contains a 'share news' button. Currently this
I have this terribly large controller in my app. I'd really like to make
I'm creating an app where users can edit their own CSS (in SCSS syntax
I am creating a web app which uses jQuery to authenticate: $.ajax({ url: /session/create?format=json,
I am creating an app which will have a question in a UILabel and
I am creating an app which has around 15 different animations. Some animations are
I am in the process of creating an app which requires irregular shaped buttons.
I'm creating an Android app which must do some web surfing in the background
I am currently creating a Dashboard app which is created with Ruby on Rails.
I'm creating a Facebook app in which I want to display content depending on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.