'Rating system in web application
I'm trying to create a rating system (as a reputation system in reddit and Stackoverflow) in my web application.
What is the right way to store that rating?
@Entity
Class User {
Long id
...
@OneToOne
CustomRating rating
}
@Entity
Class CustomRating {
@ManyToOne
Set<User> upvotes;
@ManyToOne
Set<User> downvotes;
}
This is the best I can do. Is it possible to make it better?
Thank you!
P.s. every vote should be unique. One person cannot vote twice
Solution 1:[1]
Since your User is going to have upvotes and downvotes by other users i suggest to have it all in User entity itself, like below
@Entity
class User {
Long id;
set<User> upVotedUsers;
set<User> downVotedUsers;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | HariHaravelan |
