Answer the question
In order to leave comments, you need to log in
How to make a database?
I have a directory of organizations. There is a section in which the list of organizations, by clicking you can go to the page of the organization. I need to implement a rating function. A registered user must be able to rate one organization once. From this, a list of organizations by rating should be built. How to implement it?
Answer the question
In order to leave comments, you need to log in
Table user_id, org_id, rating for the log of who exactly voted for what and how. Composite primary key by user_id & org_id (or possibly org_id & user_id). In this table, check if this user has already voted for this organization.
In the table of organizations, a rating field with an aggregated value of the current rating, possibly the number of voters, and what else is needed for display. Do not calculate the rating at runtime from the votes table.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question