So, we are building some sort of a ‘debate’ game. There are different game types, duel and group discussions, both of them have a couple of defined rules, such as length of the debate, participants limits etc.
debates
id
title
body
created
modified
debate_posts
id
debate_id
body
user_id
created
modified
debate_participants
user_id
debate_id
What I need to know is how can I check when the debate is starting (must be at least two participants) Should I store some timestamp or something similar on when the second one joins?
The second thing I’d like to know is how can I define a winner, should I have a third table, defining the “winner” of a debate, user_id and debate_id?
I’m not quite sure what kind of details I should add to the question, but If there are anything you could provide me with, I would be happy to hear about it.
Update
The debaters will be able to make the posts until the time goes out, then there will be other users voting if which users/group wins.
I’d imagine you’d need a timestamp of when the second participate joins to know when the debate started. Anytime a user joins a debate query debate_participants to see how many distinct users are in that particular debate and if there is one, then the new participant will be the second and set the start timestamp in debates.
Another way to find out when the debate started would to be to find the earliest time that a post was made in the debate by a second user in the debate_posts table.
To define a winner, if there is at most one winner, you could just add a winner_id field to debates that is the key to wherever you store users.