SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Advice on plan of attack

    OK, I have a large web based questionaire form I am constructing using PHP/MySql. There are around 50 questions with each question having anywhere between 4 and 30 possible answers, depending on the question, that the user can select using checkboxes, meaning they can have multiple checkbox answers per question.

    My question is what would be the best method to store the checkbox data in MySql, keeping in mind there is also is going to be a search routine that will need to pull the data back out efficiently?

    Should I | delimit each checkbox answer in a mysql field for each question so there are 50 fields with pipe delimited responses, or do I make a field in the table for each possible answer (around 750 fields)? Or is their a better method???

    With so many checkbox answers, what is the best/ most efficient way to store their responses knowing the data will need to be searchable?

    I can get through the programming side of it, although I am not an expert by any stretch of the imagination. Just looking for advice on how to set it up before I get started.

    Don't want to do it one way then discover later that the search is too slow because I didn't lay it out right first

    Thanks in advance!

  2. #2
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In addition, would it be best to store the data as the text answer or would it be better to give each possible answer a number and that number gets stored in the db?


    Thanks!

  3. #3
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Don't pipe-delimit the responses... keep the fields atomic.

    Code:
    Question
    ---------
    id
    question_text
    
    Answer_Options
    ----------------
    id
    question_id
    option_text
    
    Answers
    --------
    submitter_id
    question_id
    answer_id
    Searching for a response is just checking if a row exists or doesn't exist in the Answers table.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •