I am creating a site similar to reddit where users can vote on links. Here are my 3 MySQL tables so far:
users
id | username | email | password
urls
id | url | description | submittedBy (references users.username) | upvotes | downvotes
comments
urlid (references url.id) | submittedBy (references users.username) | description
My question is; How would I document who upvotes and downvotes each url. I don't know if I need to
You need another table that stores the user id, the url id and the vote. I would use a simple u|d for up or down but you could use 0|1 or anything that you like.
votes
url_id | user_id | vote
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.