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
Since your
Useris going to have upvotes and downvotes by other users i suggest to have it all inUserentity itself, like below