Polls themselves are inside the table poll
. There is another table called poll_option
. Let's assume we have the following poll:
- Name: Poll 1
- Option 1: This is poll 1
- Option 2: This is NOT poll 5
In poll
, there'd be:
id
, poll_name
, date_created
for example. poll_option
would then contain id
, option_name
, poll_id
. poll_id
would be the poll this option is a part of.
There would of course be the need for voting, so a third table is needed: poll_votes
. poll_vote
merely contain id
, date_created
and user_id
. user_id
is either the IP, a cookie, or a session key of the user. Straw Poll saves a cookie called uid
as to identify if you have already voted in this poll.
Putting it all together:
TABLE: poll
id | poll_name | date_created
62 | Poll 1 | 2014-01-11 12:34:56
TABLE: poll_option
id | option_name | poll_id
844 | This is poll 1 | 62
844 | This is NOT poll 5 | 62
TABLE: poll_vote
id | user_id | date_created
1104 | 482424 | 2014-01-12 13:53:55