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

  • SEARCH
  • Home
  • 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 6986321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:47:39+00:00 2026-05-27T18:47:39+00:00

I have a voting system for articles. Articles are stored in ‘stories’ table and

  • 0

I have a voting system for articles. Articles are stored in ‘stories’ table and all votes are stored in ‘votes’ table. id in ‘stories’ table is equal to item_name in ‘votes’ table (therefore each vote is related to article with item_name).

I want to make it so when sum of votes gets to 10 it updates ‘showing’ field in ‘stories’ table to value of “1”.

I was thinking about setting up a cron job that runs every hour to check all posts that have a showing = 0. If showing = 0 than it will sum up votes related to that article and set showing = 1 if sum of votes >= 10. I’m not sure if it is efficient as it might take up a lot of server resources, not sure.

So could anyone suggest a cron job that could do the task?

Here is my database structure:

Stories table

enter image description here


Votes table

enter image description here


Edit:

For example this row from ‘stories’ table:

id| 12
st_auth | author name
st_date | story date
st_title| story title
st_category| story category
st_body| story body
showing| 0 for unaproved and 1 for approved

This row is related to this one from ‘votes’ table

id| 83
item_name| 12 (id of article)
vote_value| 1 for upvote -1 for downvote
…

  • 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-05-27T18:47:40+00:00Added an answer on May 27, 2026 at 6:47 pm

    Couple of things:

    1. Why did you name the column item_name in the votes table, when it is actually the id of the article table? I would recommend making this a match on the article table in that it is an int(11) vs a var_char(255). Also, you should add a foreign key constraint to the votes table, so if an article is ever deleted, you don’t orphan a row in the votes table.

    2. Why is the vote_value column an int(11)? If it can only be two states (1, or -1) you can do a tinyint(1) signed (for the -1).

    3. The ip column in the votes table is a bit concerning. If you are regulating ‘unique’ votes by ip, did you account for proxy ips? Something like this should be handled at the account level, so several users from the same proxy IP can issue individual votes.

    4. I wouldn’t do a cronjob for determining whether the showing column should be flagged 0 or 1. Rather, I would issue a count every time a vote was cast against the article. So if someone up-voted or down-voted, calculate the new value of the story, and store it in cache for future reads.

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

Sidebar

Related Questions

Right now I have a voting system on my website that stores all votes
I have voting system on my website, it stores each users vote in table
I have a project involving a web voting system. The current values and related
I have a voting system with two models: Item(id, name) and Vote(id, item_id, user_id).
I have a jquery powered voting system, and the items on other pages are
I am working on a comment voting system. I have a page profile_new.php?id=194 That
i have a voting system that you dont have to login to and i
I have a voting system which sends an id of the clicked item to
Im trying to implement a voting system similar to stackoverflow and I have something
In my page I have a voting possibility. Each object can be liked with

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.