There are three tables (in parentheses):

  • users (id, username, password, created)
  • rating (id, username, comment)
  • comments(id, comment, username, created)

How would I better associate the rating table with the users and comments tables so that each comment has its own rating, and each user also has his rating, just like on this service.

How can you initially set the rating field to 0 by default, and then either increase by 1 or decrease by -1?

    1 answer 1

    It is better to add a rating field to each table, user, and comment.

    • Thank you, but how can you initially set the default rating field to 0, and then either increase by 1 or decrease by -1? - spoil
    • one
      Well, looking at what you write ..., 0 you can set by devolt, and the rating should change dynamically with the help of who works with this table - Gorets
    • I am writing in PHP + MySQL. I want to make it so that when the comment rating is increased by 1, the user rating increases by 5 - at the same time! - spoil