Need design advice

Discussion in 'MySQL' started by Exoskeletor, Mar 19, 2011.

  1. #1
    i need to store 60 answers from some questions. which is the best approach:
    for every user that takes the questions to have a record in a table with 60+ columns or to store them in another table that only stores user, question_id and answer?
    It must be anonymously also
     
    Exoskeletor, Mar 19, 2011 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If your storing a user then it isnt going to be anonymous; though you can display the answers without the user details and thus make it anonymous to the markers even if it isnt anonymous in the database.
     
    AstarothSolutions, Mar 19, 2011 IP
  3. Exoskeletor

    Exoskeletor Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes you have right i dont need the user but i need them stores in sql
     
    Exoskeletor, Mar 19, 2011 IP
  4. Exoskeletor

    Exoskeletor Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    may i ask something else. i have 60 questions that i want to show and to do that i have to do at once 4 queries for every questions, which means 240 queries at once. is this very bad? should i do only one that getss all the information i need and then to sort/show it with php?
     
    Exoskeletor, Mar 21, 2011 IP
  5. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #5
    What are your 4 queries for every question?
     
    AstarothSolutions, Mar 22, 2011 IP
  6. Exoskeletor

    Exoskeletor Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    $qry="select answers.id_ans,answers.sub_no,answers.sub_question,answers.answer,questions.type from answers,questions where answers.id_ans=questions.id_questions and id_ans=$num";

    this is the main query to take every answer for a question, im also thinking if it is wise to count numeric answers with sql and to find perstenages. for example for a yes or no type queston to do this:

    $qry="select count(answers.answer) from answers where answers.id_ans=$num and answer='yes'";
    $qry="select count(answers.answer) from answers where answers.id_ans=$num and answer='no'";
    $qry="select count(answers.answer) from answers where answers.id_ans=$num and answer='no' or answer='yes'";

    Ans if someone wants to see all the answer to create a loop to do this for every question. is there a way to do all of those in one query? should i do it or should i take all the answers from all the questions with one query

    in some other cases it is not so simple to find the ammount of an answer because i have multiple choice answers so in those i presume i have to find the number of every answer in php
     
    Last edited: Mar 22, 2011
    Exoskeletor, Mar 22, 2011 IP