Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- need advice on database design


LifeinAsia - 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.


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4179405.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com