homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

need advice on database design

5+ Year Member

Msg#: 4179405 posted 7:44 pm on Jul 30, 2010 (gmt 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.



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

Msg#: 4179405 posted 8:58 pm on Jul 30, 2010 (gmt 0)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved