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 6166577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:21:43+00:00 2026-05-23T22:21:43+00:00

i am looking for help on an up down voting system. at the moment

  • 0

i am looking for help on an up down voting system.

at the moment i have a voting table that references the user that voted , the user who was voted for and the piece of information(a parking spot) that was voted for

CREATE TABLE parking_spots_votes(
vote_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,

parking_spot_id INTEGER DEFAULT NULL,
    key  parking_spot_id_fk (parking_spot_id),
    FOREIGN KEY (parking_spot_id) REFERENCES parking_spots(id),

uploaded_by_user_id INTEGER DEFAULT NULL,
    key  user_id_fk (uploaded_by_user_id),
    FOREIGN KEY (uploaded_by_user_id) REFERENCES parking_angel_users(id),

vote_casted_user_id INTEGER DEFAULT NULL,
    key  vote_cast_user_id_fk (vote_casted_user_id),
    FOREIGN KEY (vote_casted_user_id) REFERENCES parking_angel_users(id),

vote_type INTEGER NOT NULL
 )

vote type can be 0 for no vote, 1 for up vote, 2 for downvote

now i am having a little logical trouble.

for example

  1. what if the user has already voted on a parking_spot
  2. How do i check if a user has already voted and if he has not then insert but if he has then do not a return voted already.

  3. How do i update a user(uploaded_by_user_id) score. plus one for an up vote and minus one for a down vote.

so the general flow would be ,

A user presses up vote, the server checks if has been voted for already, if so then you cant vote again.
if not then the vote_casted_user_id = current user , parking_spot_id = current info , uploaded_by_user_id = the person who uploaded the info ,
then the uploaded_by_user score would update depending on the vote type.

I am using java servlet with a JDBC connection to a MYSQL database.

Any ideas for me?

  • 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-23T22:21:44+00:00Added an answer on May 23, 2026 at 10:21 pm

    You can consider setting your primary key with parking_spot_id,uploaded_user_id,casted_user_id

    so when a vote comes from same user for same parking spot of the same uploaded user you can catch the exception and handle it that “you have already voted!”

    If you don’t like this
    You can handle process by writing your own control mechanism

    before saving vote write a select that get count of the records with parking_spot_id,uploaded_user_id,casted_user_id if the count greater than 0 this means already have a vote then don’t save and give your message.Otherwise save your vote and select user’s score increase it by vote and update the record.

    Hope this helps.

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

Sidebar

Related Questions

I was looking for rake tasks that would help me track down syntax errors,
I am looking for help in determining if the class model that I am
LINQ gurus, I am looking for help to write a query... I have a
This might be too opinionated a question, but looking for help! I have been
I need some help tracking down a bit of nitty gritty information on the
I have a variable that very rarely gets an incorrect value. Since the system
Just looking for some pointer before I head down the wrong path. I have
I have been looking for help online on how to design my php classes
I've been Googling around and looking at Emacs built-in help but I have yet
Thanks for all your help, as usual, i am looking for some more information...

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.