Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

need advice on database design

7:44 pm on Jul 30, 2010 (gmt 0)

New User

5+ Year Member

joined:Apr 11, 2010
votes: 0

Hi. I have a survey form where users can check multiple check boxes per question. This would be simple to build if users can only select one answer per question. My question is what is the best way to design/build this database? Thanks.
8:58 pm on July 30, 2010 (gmt 0)

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
votes: 109

Do you want to:
A) match users to questions (i.e., know what answers each user chose for each question), or
B) have an anonymous survey (i.e., don't care about tying answers to individual users)?

If A, then the following table (called Answers) would work:
UserNumber | QuestionNumber | Answer

You'd probably also need a Users table for tracking:
UserNumber | UserName

Create 1 row in the Answers table for each answer. For example, let's say User 1 selects A & C for question 2. Your table would look like:
UserNumber | QuestionNumber | Answer
1 | 2 | A
1 | 2 | C

If B, then use the same logic, but drop the UserNumber field and Users table.