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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:30:54+00:00 2026-06-15T19:30:54+00:00

I have three tables in my RDBMS (most often MySQL or Postgresql) which I

  • 0

I have three tables in my RDBMS (most often MySQL or Postgresql) which I want to use when calculating votes. The first is a user table where users have different levels of pull (weight), the second is a table which records their vote on an item, and the third is the item table itself.

The idea is that moderators, or users that have been around longer should have more “weight” when casting votes.

USER {
    id,
    weight int,
}

VOTE {
    vote int,
    user_id,
    item_id,
}

ITEM {
    id
}

I want to calculate votes for items based on the weight of the user voting in addition to the number of votes. So if user 100 and 101 both have a weight of 1 and vote a score of “3”, and user 102 with a weight of 10 comes along and votes “5” then we assign more value to vote cast by this user 102.

Perhaps something simple like the total user weight of all users combined being used to divide the votes.

(user:weight * vote) / sum(user:weight))

Perhaps I should use some other formula to curve the power of the users with the most weight in the system.

How can I calculate votes taking a third variable like the power of the user into account?

For that mater, how should I calculated weight? Perhaps I could add the combined weight of all users up, then divide by the total number of users to find an average weight I can used to give the user a weight of between 1 and 100 so it’s easier to work with.

  • 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-15T19:30:55+00:00Added an answer on June 15, 2026 at 7:30 pm

    You can just do the arithmetic in an aggregation:

    select v.item_id,
           (case when sum(u.weight) > 0 then sum(u.weight * v.vote) / sum(u.weight) end) as weightedVote
    from vote v join
         user u
         on v.user_id = u.id
    group by v.item_id
    

    How you calculate the weights is a different matter. That query shows how to use them.

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

Sidebar

Related Questions

I have three tables (individuals, groups & recordlabels) and want use the information between
I have three tables which I want to combine into one view or temporary
I have three tables in a Mysql database - countries, cities and hotels. Their
I have three tables. I have to retrieve the data using Linq statement. My
I have three tables of data: table: cars [10,000 rows] table: planes [2,000 rows]
I have three tables: Employee(EmployeeID,Fname,Lname...) ProjectHeader(ProjectID,LeadID,Status....) ProjectDetails(ProjectDetailsID,ProjectID....) Here's my current code: $get_projects = SELECT
I have three tables as shown in below image. Note: Lead column of projectheader
I have three tables Author, Book and AuthorBook. AuthorBook table only contains two foreign
I have three tables in oracle db as newitems, itemdetails, ticketitems table. Some dummy
I have three tables: upload, tag and upload_tag. Upload holds details of a file

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.